/* CSS Design System for 'The Art of Thinking Clearly' Companion App */

:root {
    --bg-base: #080C14;
    --bg-surface: #0F1626;
    --bg-card: rgba(23, 32, 53, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --color-primary: #3B82F6;
    --color-secondary: #06B6D4;
    --color-accent: #10B981;
    --color-text-main: #F3F4F6;
    --color-text-muted: #9CA3AF;
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-base);
    color: var(--color-text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #0F172A 0%, #020617 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 3rem 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.header-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.header-accent {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--color-secondary);
    display: inline-block;
    margin-bottom: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(6, 182, 212, 0.1);
    border-radius: 99px;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #FFF;
    margin-bottom: 0.5rem;
}

.app-header p {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.workspace-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    color: #FFF;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

.workspace-btn:hover {
    background: #FFF;
    color: var(--bg-base);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.icon-open {
    width: 16px;
    height: 16px;
}

/* Main Layout */
.app-main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Controls (Search & Filters) */
.controls-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.search-wrapper {
    position: relative;
    margin-bottom: 1.25rem;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    pointer-events: none;
}

#search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1rem 1rem 3.25rem;
    color: #FFF;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition-smooth);
}

#search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.filters-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-pills {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
}

.filter-pills::-webkit-scrollbar {
    display: none;
}

.pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.pill:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #FFF;
}

.pill.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Switch styling */
.toggle-wrapper {
    display: flex;
    align-items: center;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.switch-label input {
    display: none;
}

.switch-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    transition: var(--transition-smooth);
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #FFF;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

input:checked + .switch-slider {
    background-color: var(--color-accent);
}

input:checked + .switch-slider::before {
    transform: translateX(20px);
}

.stats-bar {
    margin-top: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
}

/* Chapters Grid */
.chapters-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Chapter Card */
.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chapter-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.chapter-badge {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
}

.chapter-info {
    flex-grow: 1;
}

.chapter-info h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #FFF;
}

.bias-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: var(--color-text-muted);
}

/* Artifacts list in card */
.artifacts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.artifact-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--color-text-main);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.artifact-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

.artifact-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.artifact-title {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Empty State */
.empty-chapter {
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

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

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    color: var(--color-text-muted);
}

.no-results h4 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: #FFF;
    margin-bottom: 0.5rem;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
}

/* Mobile Responsiveness Rules */
@media (max-width: 640px) {
    .app-header {
        padding: 2rem 1rem;
    }
    
    .app-header h1 {
        font-size: 1.75rem;
    }
    
    .app-main {
        padding: 1rem;
    }
    
    .controls-section {
        padding: 1rem;
        border-radius: 16px;
    }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-pills {
        justify-content: flex-start;
        padding-bottom: 0.5rem;
    }
    
    .toggle-wrapper {
        justify-content: flex-start;
        border-top: 1px solid var(--border-color);
        padding-top: 0.75rem;
    }
    
    .artifacts-list {
        grid-template-columns: 1fr;
    }
    
    .chapter-card {
        padding: 1rem;
        border-radius: 14px;
    }
    
    .chapter-info h3 {
        font-size: 1.05rem;
    }
}

/* Lock Screen Styles */
.hidden {
    display: none !important;
}

#lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 9999;
}

.lock-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
}

.lock-badge {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    display: inline-block;
    margin-bottom: 1rem;
}

.lock-card h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #FFF;
}

.lock-card p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

#passcode-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#passcode-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    color: #FFF;
    font-family: var(--font-body);
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    text-align: center;
    transition: var(--transition-smooth);
}

#passcode-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

#passcode-input::placeholder {
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.15);
}

.error-msg {
    color: #EF4444;
    font-size: 0.8rem;
    font-weight: 600;
    display: none;
}

.submit-btn {
    background: var(--color-primary);
    border: none;
    color: #FFF;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.submit-btn:hover {
    background: #2563EB;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

body.locked {
    overflow: hidden !important;
    height: 100vh !important;
    width: 100vw !important;
}

/* Media Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 10, 12, 0.75);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 100%;
    max-width: 900px;
    height: auto;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modal-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-title-group h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: #FFF;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.type-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #FFF;
    text-transform: uppercase;
}

.type-badge.audio {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: var(--color-primary);
}

.type-badge.video {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10B981;
}

.type-badge.slide_deck {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #F59E0B;
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #FFF;
}

.close-btn svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: 1.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
}

.player-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Video Player Layout */
#player-video {
    width: 100%;
    border-radius: 14px;
    max-height: 55vh;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    background: #000;
}

/* Slide Deck iframe Layout */
#player-iframe {
    width: 100%;
    height: 60vh;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

/* Audio Card layout */
.audio-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.audio-cover {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--color-primary), #1E40AF);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.cover-icon {
    font-size: 3rem;
}

.audio-info h4 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: #FFF;
    margin-bottom: 0.25rem;
}

.audio-info p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.custom-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.time-slider-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.time-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    width: 32px;
}

.progress-bar {
    flex-grow: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}

.progress-bar::-webkit-slider-value-token {
    background: var(--color-primary);
}

.progress-bar::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.1);
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
    transition: transform 0.1s ease;
}

.progress-bar::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.control-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--color-text-muted);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #FFF;
}

.control-btn svg {
    margin-top: 2px;
}

.skip-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-top: -1px;
}

.control-btn:hover .skip-label {
    color: #FFF;
}

.play-pause-btn {
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.play-pause-btn:hover {
    background: #2563EB;
    color: #FFF;
    transform: scale(1.05);
}

.play-pause-btn svg {
    width: 22px;
    height: 22px;
}

/* Mobile responsive modals */
@media (max-width: 768px) {
    .modal-container {
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 1rem 1.25rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    #player-iframe {
        height: 50vh;
    }
    
    .audio-card {
        padding: 1.5rem 1.25rem;
    }
}

/* Modal Actions Header */
.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.external-link-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.external-link-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #FFF;
}

/* Fallback Card Styling */
.error-card, .slide-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.error-icon, .slide-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    font-size: 2.5rem;
}

.error-icon {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #EF4444;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.15);
}

.slide-icon {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #F59E0B;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
}

.error-card h4, .slide-card h4 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: #FFF;
    margin-bottom: 0.5rem;
}

.error-card p, .slide-card p {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
    max-width: 320px;
}

.fallback-action-btn {
    background: var(--color-primary);
    color: #FFF;
    border: none;
    padding: 0.85rem 1.75rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
    transition: var(--transition-smooth);
    width: 100%;
    max-width: 280px;
}

.fallback-action-btn:hover {
    background: #2563EB;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.fallback-action-btn.error-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #FFF;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.fallback-action-btn.error-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}


