/* Read to Me Podcast Player Styles */
/* Modern, responsive design for podcast playback */

/* CSS Variables for theming */
/* Default Palette: Minimal Monochrome (Pure black with teal accents) */
:root, [data-theme="minimal-monochrome"] {
    /* Primary/Interactive Colors */
    --primary-color: #14b8a6;
    --primary-hover: #2dd4bf;
    --secondary-color: #6b7280;

    /* Background Colors */
    --background: #000000;
    --surface: #1a1a1a;
    --surface-hover: #2d2d2d;

    /* Border Colors */
    --border: #3d3d3d;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;

    /* State Colors */
    --active-text: #000000;
    --overlay-background: rgba(0, 0, 0, 0.95);

    /* Semantic Colors */
    --success: #10b981;
    --success-background: #064e3b;
    --error: #ef4444;
    --error-background: #450a0a;
    --error-border: #991b1b;
    --info-background: #134e4a;
    --info-border: #115e59;

    /* Shadows (adjusted for dark theme) */
    --shadow-sm: 0 1px 2px 0 rgb(255 255 255 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(255 255 255 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(255 255 255 / 0.1);

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Palette 1: Midnight Slate (Cool blue-gray, professional) */
[data-theme="midnight-slate"] {
    /* Primary/Interactive Colors */
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary-color: #64748b;

    /* Background Colors */
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;

    /* Border Colors */
    --border: #334155;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* State Colors */
    --active-text: #ffffff;
    --overlay-background: rgba(15, 23, 42, 0.95);

    /* Semantic Colors */
    --success: #22c55e;
    --success-background: #14532d;
    --error: #f87171;
    --error-background: #450a0a;
    --error-border: #7f1d1d;
    --info-background: #1e3a8a;
    --info-border: #1e40af;

    /* Shadows (adjusted for dark theme) */
    --shadow-sm: 0 1px 2px 0 rgb(148 163 184 / 0.15);
    --shadow-md: 0 4px 6px -1px rgb(148 163 184 / 0.2);
    --shadow-lg: 0 10px 15px -3px rgb(148 163 184 / 0.25);
}

/* Palette 2: Charcoal Warmth (Warm gray with amber accents) */
[data-theme="charcoal-warmth"] {
    /* Primary/Interactive Colors */
    --primary-color: #f59e0b;
    --primary-hover: #fbbf24;
    --secondary-color: #9ca3af;

    /* Background Colors */
    --background: #1a1a1a;
    --surface: #262626;
    --surface-hover: #404040;

    /* Border Colors */
    --border: #404040;

    /* Text Colors */
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;

    /* State Colors */
    --active-text: #000000;
    --overlay-background: rgba(26, 26, 26, 0.95);

    /* Semantic Colors */
    --success: #84cc16;
    --success-background: #365314;
    --error: #fb923c;
    --error-background: #431407;
    --error-border: #9a3412;
    --info-background: #713f12;
    --info-border: #92400e;

    /* Shadows (adjusted for dark theme) */
    --shadow-sm: 0 1px 2px 0 rgb(163 163 163 / 0.15);
    --shadow-md: 0 4px 6px -1px rgb(163 163 163 / 0.2);
    --shadow-lg: 0 10px 15px -3px rgb(163 163 163 / 0.25);
}

/* Palette 3: Slate Gray (Inspired by Daring Fireball - medium slate with sky blue accents) */
[data-theme="slate-gray"] {
    /* Primary/Interactive Colors */
    --primary-color: #0ea5e9;
    --primary-hover: #38bdf8;
    --secondary-color: #94a3b8;

    /* Background Colors */
    --background: #4b5563;
    --surface: #6b7280;
    --surface-hover: #9ca3af;

    /* Border Colors */
    --border: #374151;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;

    /* State Colors */
    --active-text: #ffffff;
    --overlay-background: rgba(75, 85, 99, 0.95);

    /* Semantic Colors */
    --success: #10b981;
    --success-background: #065f46;
    --error: #ef4444;
    --error-background: #7f1d1d;
    --error-border: #991b1b;
    --info-background: #0c4a6e;
    --info-border: #075985;

    /* Shadows (adjusted for medium-gray theme) */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    /* iOS safe area support - body background matches header/footer color */
    background-color: var(--primary-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Application Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    z-index: 50; /* Ensure header stays below fixed player (z-index: 100) */
    background-color: var(--primary-color);
    color: var(--active-text);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-md);
    /* iOS safe area support - extend header into safe area */
    margin-top: calc(-1 * env(safe-area-inset-top, 0px));
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    padding-left: calc(2rem + env(safe-area-inset-left, 0px));
    padding-right: calc(2rem + env(safe-area-inset-right, 0px));
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: nowrap; /* Prevent wrapping */
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    flex: 1 1 auto; /* Allow h1 to grow/shrink */
    min-width: 0; /* Allow h1 to shrink below content size */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header .subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Settings Button */
.settings-button {
    background: transparent;
    border: none;
    color: var(--active-text);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    flex-shrink: 0; /* Never shrink button */
}

.settings-button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

.settings-button:active {
    transform: rotate(45deg) scale(0.95);
}

.settings-button svg {
    width: 24px;
    height: 24px;
}

/* Settings Backdrop */
.settings-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease-out;
    z-index: 140;
}

.settings-backdrop.visible {
    opacity: 1;
}

/* Main Content */
.app-main {
    display: flex;
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    /* iOS safe area support for horizontal padding */
    padding-left: calc(2rem + env(safe-area-inset-left));
    padding-right: calc(2rem + env(safe-area-inset-right));
    /* Dark background for main content area */
    background-color: var(--background);
}

/* Sidebar */
.sidebar {
    width: 280px;
    flex-shrink: 0;
}

.sidebar h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Content Area */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0; /* Allow flex item to shrink below content size */
}

.episodes-container {
    flex: 1;
}

.episodes-container h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Player Container - Slide-up from bottom */
.player-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    z-index: 100;
    max-width: 100%;
    /* iOS safe area support for bottom player */
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    padding-left: calc(1.5rem + env(safe-area-inset-left));
    padding-right: calc(1.5rem + env(safe-area-inset-right));
}

.player-container.visible {
    transform: translateY(0);
}

/* Footer */
.app-footer {
    background-color: var(--primary-color);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--active-text);
    font-size: 0.875rem;
    /* iOS safe area support - extend footer into bottom safe area */
    margin-bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(2rem + env(safe-area-inset-left, 0px));
    padding-right: calc(2rem + env(safe-area-inset-right, 0px));
}

.app-footer a {
    color: var(--active-text);
    font-weight: 500;
    text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Responsive Design */

/* Tablet */
@media (max-width: 1024px) {
    .app-main {
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .sidebar {
        width: 240px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-header {
        padding: 1.25rem 1rem;
        /* iOS safe area support - extend header into safe area */
        margin-top: calc(-1 * env(safe-area-inset-top, 0px));
        padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
        padding-left: calc(1rem + env(safe-area-inset-left, 0px));
        padding-right: calc(1rem + env(safe-area-inset-right, 0px));
    }

    .header-content {
        gap: 1rem; /* Reduce gap on mobile */
    }

    .app-header h1 {
        font-size: 1.5rem;
    }

    .settings-button {
        width: 36px;
        height: 36px;
    }

    .settings-button svg {
        width: 20px;
        height: 20px;
    }

    .app-main {
        flex-direction: column;
        padding: 1rem;
        gap: 1.5rem;
        /* iOS safe area support for mobile */
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
    }

    .sidebar {
        width: 100%;
    }

    .content {
        gap: 1.5rem;
    }

    .player-container {
        border-radius: 0;
        border-top: 1px solid var(--border);
        padding: 1rem;
        /* iOS safe area support for mobile player */
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.25rem;
    }

    .app-header .subtitle {
        font-size: 0.85rem;
    }

    .app-main {
        padding: 0.75rem;
        /* iOS safe area support for small mobile */
        padding-left: calc(0.75rem + env(safe-area-inset-left));
        padding-right: calc(0.75rem + env(safe-area-inset-right));
    }

    .episodes-container h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.error-message {
    background-color: var(--error-background);
    border: 1px solid var(--error-border);
    color: var(--error);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
}

.info-message {
    background-color: var(--info-background);
    border: 1px solid var(--info-border);
    color: var(--primary-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
}

/* Print Styles */
@media print {
    .player-container,
    .app-header,
    .app-footer,
    .loading-overlay {
        display: none !important;
    }

    .app-main {
        display: block;
    }

    .sidebar {
        width: 100%;
    }
}
