/* style.css */

:root {
    /* Color Palette - Updated */
    --bg-dark: #1e1e1e;
    --bg-card: #2d2d2d;
    --bg-sidebar: #252526; /* Slightly different dark for sidebar */
    --text-light: #f0f0f0;
    --text-medium: #a0a0a0;
    --text-dark: #1e1e1e; /* For light backgrounds like buttons */

    /* -- Primary Accent (Vibrant Blue) -- */
    --primary-accent: #3498db; /* Vibrant Blue */
    --primary-accent-hover: #2980b9; /* Darker Blue */
    --primary-accent-light: rgba(52, 152, 219, 0.1); /* Light blue for backgrounds */

    /* -- Secondary Accent (Bright Orange) -- */
    --secondary-accent: #ffa500; /* Bright Orange */
    --secondary-accent-hover: #e69500; /* Darker Orange */

    /* -- Other Colors -- */
    --danger-color: #e74c3c;
    --danger-color-hover: #c0392b;
    --border-color: #444;
    --font-family: 'Roboto', sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);

    /* Layout Variables */
    --sidebar-width-expanded: 240px;
    --sidebar-width-collapsed: 60px; /* Width for icons only */
    --header-height: 60px; /* Approximate height of the header */
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
}

header {
    background-color: var(--bg-card);
    box-shadow: var(--box-shadow);
    height: var(--header-height);
    display: flex;
    align-items: center;
    /* Change justify-content to space-between to position items */
    justify-content: space-between;
    padding: 0 15px; /* Adjust padding if needed */
    position: sticky; /* Keep header visible */
    top: 0;
    z-index: 1000; /* Ensure header is above sidebar/content */
}

header h1 {
    color: var(--primary-accent); /* Use new primary color */
    font-weight: 700;
    font-size: 2em; /* Adjusted size slightly */
     /* Remove auto margin if space-between is used */
     margin: 0;
}

.header-right {
    /* Placeholder for potential future items like user avatar/logout */
    min-width: 40px; /* Ensure it takes some space to balance the toggle */
    /* Needs content or specific width/height if used */
    display: flex; /* Align items if needed */
    align-items: center;
}

/* Main Layout Wrapper */
.app-wrapper {
    display: flex;
}

/* Sidebar Styles */
#sidebar {
    width: var(--sidebar-width-expanded);
    height: calc(100vh - var(--header-height)); /* Full height below header */
    background-color: var(--bg-sidebar);
    padding: 15px 0; /* Padding top/bottom, no horizontal padding for links */
    position: fixed; /* Fixed position relative to viewport */
    top: var(--header-height); /* Position below the header */
    left: 0;
    bottom: 0;
    z-index: 999; /* Below header, above content overlay on mobile */
    overflow-y: hidden; /* Prevent vertical scrollbar */
    overflow-x: hidden; /* Hide horizontal overflow */
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
    border-right: 1px solid var(--border-color);
}

/* Generic Toggle Button Style */
.sidebar-toggle-button {
    background: none;
    border: none;
    color: var(--text-medium);
    font-size: 1.8em;
    cursor: pointer;
    padding: 5px 10px; /* Consistent padding */
    display: flex; /* Use flex for alignment */
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed) ease;
    line-height: 1; /* Ensure icon vertical centering */
}
.sidebar-toggle-button:hover {
    color: var(--text-light);
}

/* Sidebar internal toggle specific placement */
#sidebar #sidebar-toggle {
    display: block; /* Default display state */
    margin: 0 auto 10px 15px; /* Original margin for desktop (align left) */
}

.sidebar-nav-list {
    list-style: none;
}

.sidebar-nav-list li a.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 18px; /* Padding inside the link */
    color: var(--text-medium);
    text-decoration: none;
    white-space: nowrap; /* Prevent text wrapping */
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    font-size: 0.95em;
}

.sidebar-nav-list li a.nav-link .icon {
    margin-right: 15px; /* Space between icon and text */
    font-size: 1.2em; /* Icon size */
    width: 24px; /* Fixed width for alignment */
    text-align: center;
    transition: margin var(--transition-speed) ease; /* Smooth transition for margin */
}

.sidebar-nav-list li a.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.sidebar-nav-list li a.nav-link.active {
    background-color: var(--primary-accent-light); /* Use light primary accent */
    color: var(--primary-accent); /* Use primary accent color */
    font-weight: 500;
    border-left: 3px solid var(--primary-accent);
    padding-left: 15px; /* Adjust padding to account for border */
}
.sidebar-nav-list li a.nav-link.active .icon {
    color: var(--primary-accent);
}

/* Collapsed Sidebar Styles */
#sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

#sidebar.collapsed .sidebar-nav-list li a.nav-link {
    justify-content: center; /* Center icon when collapsed */
}

#sidebar.collapsed .sidebar-nav-list li a.nav-link .icon {
    margin-right: 0; /* Remove margin when collapsed */
}

#sidebar.collapsed .sidebar-nav-list li a.nav-link span:not(.icon) {
    display: none; /* Hide text */
}

/* Center the internal toggle when sidebar is collapsed */
#sidebar.collapsed #sidebar-toggle {
     margin: 0 auto 10px auto;
}


/* Main Content Area */
#main-content {
    flex-grow: 1; /* Take remaining space */
    margin-left: var(--sidebar-width-expanded);
    padding: 25px;
    transition: margin-left var(--transition-speed) ease;
    min-width: 0; /* Prevent content from overflowing flex container */
}

#sidebar.collapsed + #main-content {
    margin-left: var(--sidebar-width-collapsed);
}

/* Tab Content Styling */
.tab-content {
    display: none; /* Hide tabs by default */
}

.tab-content.active {
    display: block; /* Show active tab */
    animation: fadeIn 0.5s ease; /* Optional fade-in */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Styles for content within tabs (reusing app-container and card) */
.app-container {
    max-width: 900px;
    margin: 0 auto; /* Center content within the tab */
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.card {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border-top: 3px solid var(--primary-accent); /* Use new primary color */
}

.card h2 {
    color: var(--text-light);
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 1.8em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.card h2 .icon {
    margin-right: 10px;
}

/* Drop Zones & Input Section */
.drop-zones-container {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}

.drop-zone {
    flex: 1;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background-color: rgba(0,0,0,0.1);
    transition: border-color 0.3s ease, background-color 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-accent);
    background-color: var(--primary-accent-light);
}

.drop-zone .preview-thumb {
    max-width: 80px;
    max-height: 60px;
    margin-bottom: 10px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}
.drop-zone .media-icon,
.drop-zone .audio-icon {
    font-size: 2.5em;
    color: var(--primary-accent);
    margin-bottom: 10px;
}

.drop-zone-text {
    font-size: 0.95em;
    color: var(--text-medium);
    margin-bottom: 5px;
}

.file-name-display {
    font-size: 0.8em;
    color: var(--text-light);
    word-break: break-all;
    margin-top: 5px;
}

.duration-preview {
    font-size: 0.8em;
    color: var(--secondary-accent);
    font-weight: 500;
    margin-top: 8px;
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 25px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.1s ease;
    text-decoration: none;
    color: white;
}
.button .icon {
    margin-right: 8px;
}

.button:active {
    transform: translateY(1px);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primary-button {
    background-color: var(--primary-accent);
    width: 100%;
}
.primary-button:hover:not(:disabled) {
    background-color: var(--primary-accent-hover);
}

.secondary-button {
    background-color: #555;
}
.secondary-button:hover:not(:disabled) {
    background-color: #666;
}

.accent-button {
    background-color: var(--secondary-accent);
    color: var(--text-dark);
}
.accent-button:hover:not(:disabled) {
    background-color: var(--secondary-accent-hover);
}

.download-button {
    background-color: var(--primary-accent);
}
.download-button:hover:not(:disabled) {
    background-color: var(--primary-accent-hover);
}


/* Timeline Section */
#timeline-list {
    list-style-type: none;
    padding: 0;
    min-height: 60px;
}

.timeline-placeholder {
    text-align: center;
    color: var(--text-medium);
    padding: 20px;
    font-style: italic;
}

#timeline-list li:not(.timeline-placeholder) {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background-color 0.3s ease;
}

#timeline-list li.active-track {
    background-color: var(--primary-accent-light);
    border-left: 4px solid var(--primary-accent);
}

#timeline-list li img.timeline-thumb,
#timeline-list li span.timeline-thumb { /* Style span placeholder too */
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    /* Added styles for span placeholder */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0,0,0,0.2); /* Give icon placeholder a bg */
}
#timeline-list li span.timeline-thumb {
    font-size: 1.5em; /* Adjust icon size */
    color: var(--text-medium);
}


#timeline-list li .details {
    flex-grow: 1;
}

#timeline-list li .details span {
    display: block;
    font-size: 0.9em;
    color: var(--text-medium);
}
#timeline-list li .details span.file-name {
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 3px;
}
#timeline-list li .details span.duration {
    color: var(--secondary-accent);
    font-size: 0.85em;
}

.delete-track-button {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2em;
    font-weight: bold;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0; /* Prevent shrinking */
}
.delete-track-button:hover {
    background-color: var(--danger-color);
    color: white;
}

/* Preview & Playback Section */
.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 20px auto;
    background-color: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
}

#main-canvas {
    display: block;
    width: 100%;
    height: auto;
    background-color: #000;
}

#recording-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(231, 76, 60, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: bold;
    z-index: 10;
}

#playback-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping */
}

.total-duration, .timer-display {
    font-size: 0.9em;
    color: var(--text-medium);
    background-color: rgba(0,0,0,0.15);
    padding: 5px 10px;
    border-radius: 4px;
}
#total-duration-display {
    margin-left: 10px;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
    color: var(--text-medium);
    font-size: 0.9em;
    border-top: 1px solid var(--border-color);
}


/* --- Control Visibility of Toggle Buttons --- */

/* Header toggle: Hidden by default on larger screens */
#header-sidebar-toggle {
    display: none;
}

/* Sidebar internal toggle: Displayed by default */
#sidebar #sidebar-toggle {
    display: block; /* Or flex if needed */
}


/* --- Responsive Design Adjustments --- */

/* Tablet and smaller desktops */
@media (max-width: 992px) {
    /* Force sidebar collapse */
    #sidebar {
        width: var(--sidebar-width-collapsed);
    }
    /* Adjust styles for collapsed state */
    #sidebar .sidebar-nav-list li a.nav-link {
        justify-content: center;
    }
    #sidebar .sidebar-nav-list li a.nav-link .icon {
        margin-right: 0;
    }
    #sidebar .sidebar-nav-list li a.nav-link span:not(.icon) {
        display: none;
    }
    #sidebar #sidebar-toggle {
        margin: 0 auto 10px auto; /* Center toggle */
    }

    /* Adjust main content margin */
    #main-content {
        margin-left: var(--sidebar-width-collapsed);
    }

    /* Show header toggle */
    #header-sidebar-toggle {
        display: block; /* Or flex */
    }

    /* Hide the toggle inside the sidebar */
    #sidebar #sidebar-toggle {
        display: none;
    }

     /* Card and content adjustments from original design */
     .card h2 {
        font-size: 1.5em;
    }
    .drop-zones-container {
        flex-direction: column;
    }
    #timeline-list li {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .delete-track-button {
        align-self: flex-end;
    }
}


/* Mobile phones */
@media (max-width: 767px) {
    /* Sidebar becomes an overlay */
    #sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width-expanded); /* Use expanded width when open */
        transition: transform var(--transition-speed) ease;
        z-index: 1001; /* Above header and content when open */
        border-right: none; /* No border needed for overlay */
        box-shadow: 5px 0 15px rgba(0,0,0,0.3); /* Add shadow for overlay */
        overflow-y: hidden; /* Ensure still hidden */
    }

    #sidebar:not(.collapsed) { /* Style when explicitly opened (not collapsed) */
         transform: translateX(0);
    }

    #sidebar.collapsed {
        /* Keep it off-screen when collapsed on mobile */
        transform: translateX(-100%);
        width: var(--sidebar-width-expanded); /* Ensure width doesn't transition weirdly */
    }

    /* Main content takes full width */
    #main-content {
        margin-left: 0;
        padding: 15px; /* Reduce padding slightly */
    }

    /* Header toggle is already displayed via previous media query */
    #header-sidebar-toggle {
         z-index: 1002; /* Ensure it's above the overlay */
         font-size: 1.9em; /* Slightly larger tap target */
    }
     /* Internal sidebar toggle remains hidden */
    #sidebar #sidebar-toggle {
        display: none;
    }

    /* Other mobile adjustments */
     header h1 {
        font-size: 1.6em;
    }
    .card {
        padding: 15px;
    }
     .card h2 {
        font-size: 1.3em;
    }
    .drop-zone {
        min-height: 150px;
    }
    /* Buttons may need width adjustments */
    .button {
        padding: 10px 20px;
        font-size: 0.95em;
    }
    #timeline-list li img.timeline-thumb,
    #timeline-list li span.timeline-thumb { /* Target span placeholder too */
        max-width: 120px;
        height: auto; /* Maintain aspect ratio */
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4em;
    }
    /* Stacking buttons in playback controls */
    #playback-controls .button {
      flex-basis: 100%;
      margin-bottom: 10px;
      width: 100%; /* Force full width */
    }
     #playback-controls .button:last-of-type { /* Target last button */
         margin-bottom: 0;
     }
    #playback-controls .timer-display {
      flex-basis: 100%;
      text-align: center;
      margin-top: 10px;
      width: 100%;
    }
    .drop-zone .audio-icon, .drop-zone .media-icon {
        font-size: 2em;
    }
    .drop-zone-text {
        font-size: 0.9em;
    }
     /* Sidebar width on small screens when open */
    /* #sidebar:not(.collapsed) { width: 220px; } */
}