/* ================================
   Torrent Downloader - Fluid Pro Layout
================================ */

html {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Fluid Page Wrapper */
.page-viewport {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
}

/* Header */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.top-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s;
}

.top-back-btn:hover {
    background: var(--card-hover);
    border-color: var(--border-hover);
    color: var(--text);
}

/* Main Content Area */
.page-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.tool-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.badge-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 1.2px;
}

.tool-head h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

/* Master Dashboard Card */
.dashboard-card {
    background: linear-gradient(145deg, rgba(18, 23, 36, 0.95), rgba(10, 14, 22, 0.98));
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    width: 100%;
}

/* Status Banner */
.dash-status-row {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.pulse-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.pulse-dot.active {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.pulse-dot.error {
    background: #ff4d4d;
    box-shadow: 0 0 12px #ff4d4d;
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-title {
    font-size: 14px;
    font-weight: 700;
}

.status-sub {
    font-size: 11px;
    color: var(--muted);
}

/* Input Panel */
.input-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.m-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.8px;
}

.custom-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    color: var(--text);
    font-size: 12px;
    outline: none;
    transition: 0.2s;
}

.custom-input:focus {
    border-color: var(--accent-light);
    background: rgba(255, 255, 255, 0.06);
}

/* Metrics Grid (2x2) */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.m-value {
    font-size: 16px;
    font-weight: 700;
    font-family: monospace;
    color: var(--text);
}

/* Files Panel */
.files-panel {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-list-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.file-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11px;
    transition: background 0.2s ease;
    border: 1px solid var(--border);
}

.file-row:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-hover);
}

.file-name {
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* --- Torrent Info Box & Action Buttons Polish --- */
.file-dl-btn {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-dl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-light);
    color: var(--accent-light);
}

/* Button Variants */
.pause-action-btn {
    background: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
    color: #60a5fa !important;
}

.pause-action-btn.resumed {
    background: rgba(0, 255, 153, 0.15) !important;
    border-color: rgba(0, 255, 153, 0.3) !important;
    color: #00ff19 !important;
}

.file-pause-toggle {
    background: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
    color: #60a5fa !important;
}

.file-pause-toggle.resumed {
    background: rgba(0, 255, 153, 0.15) !important;
    border-color: rgba(0, 255, 153, 0.3) !important;
    color: #00ff19 !important;
}

.cancel-btn, #closePlayerBtn {
    background: rgba(255, 77, 77, 0.15) !important;
    border-color: rgba(255, 77, 77, 0.3) !important;
    color: #ff4d4d !important;
}

.play-action-btn {
    background: rgba(138, 43, 226, 0.15) !important;
    border-color: rgba(138, 43, 226, 0.35) !important;
    color: #9cb8d9 !important; /* Soft #3989ff-blue tone */
}

.play-action-btn:hover {
    background: rgba(138, 43, 226, 0.25) !important;
    border-color: rgba(138, 43, 226, 0.6) !important;
    color: #ffffff !important;
}

.save-action-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

/* --- Custom Styled Audio Player & Wave Visualizer --- */
.custom-audio-player {
    width: 100%;
    height: 38px;
    outline: none;
    border-radius: 8px;
    accent-color: var(--accent);
    filter: invert(1) hue-rotate(180deg) brightness(1.5); /* Gives it a sleek dark modern aesthetic */
}

.wave-bars-container {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
}

.wave-bar {
    width: 5px;
    background: var(--accent);
    border-radius: 3px;
    height: 10px;
    transition: height 0.2s ease;
}

/* Active Wave Animation States */
.wave-bars-container.playing .wave-bar {
    animation: wavePulse 0.9s ease-in-out infinite alternate;
}

.wave-bars-container.playing .wave-bar:nth-child(1) { animation-delay: 0.1s; }
.wave-bars-container.playing .wave-bar:nth-child(2) { animation-delay: 0.3s; }
.wave-bars-container.playing .wave-bar:nth-child(3) { animation-delay: 0.15s; }
.wave-bars-container.playing .wave-bar:nth-child(4) { animation-delay: 0.4s; }
.wave-bars-container.playing .wave-bar:nth-child(5) { animation-delay: 0.25s; }
.wave-bars-container.playing .wave-bar:nth-child(6) { animation-delay: 0.35s; }
.wave-bars-container.playing .wave-bar:nth-child(7) { animation-delay: 0.05s; }

@keyframes wavePulse {
    0% { height: 8px; opacity: 0.4; }
    100% { height: 36px; opacity: 1; }
}

/* --- Custom Media Player UI Alignment --- */
#customPlayerContainer {
    background: linear-gradient(145deg, rgba(12, 17, 28, 0.98), rgba(6, 9, 15, 0.99));
    border: 1px solid var(--accent-light);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 12px 30px rgba(0, 255, 153, 0.15);
    margin-top: 10px;
}

.media-wrapper {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    position: relative;
}

#customVideoElement {
    width: 100%;
    max-height: 300px;
    outline: none;
    background: #000;
    display: block;
}

/* Action Button */
.primary-btn {
    padding: 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    background: var(--accent);
    color: #000;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 255, 153, 0.25);
    transition: 0.2s;
    width: 100%;
}

.primary-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.divider-text {
    font-size: 9px;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
    letter-spacing: 1px;
    margin: 2px 0;
}

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.upload-dropzone:hover {
    border-color: var(--accent-light);
    background: rgba(255, 255, 255, 0.03);
}

.dropzone-icon {
    font-size: 20px;
}

.dropzone-text {
    font-size: 11px;
    color: var(--text);
}

/* Footer */
.page-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 8px 0;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
    width: 100%;
    margin-top: auto;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}
