/* ========================================
   Story Voices Demo - Professionals UX/UI
   ======================================== */

/* Modern Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    /* Professional Blue Palette (Light Mode) */
    --primary-color: #2563eb;
    /* Blue 600 */
    --primary-hover: #1d4ed8;
    /* Blue 700 */
    --primary-soft: #eff6ff;
    /* Blue 50 */

    --bg-body: #f8fafc;
    /* Slate 50 */
    --bg-surface: #ffffff;
    /* White */
    --bg-surface-alt: #f1f5f9;
    /* Slate 100 */

    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #94a3b8;
    /* Slate 400 */

    --border-light: #e2e8f0;
    /* Slate 200 */
    --border-focus: #3b82f6;
    /* Blue 500 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --success: #10b981;
    --error: #ef4444;
}

[data-theme="dark"] {
    /* Professional Blue Palette (Dark Mode) */
    --primary-color: #3b82f6;
    /* Blue 500 */
    --primary-hover: #60a5fa;
    /* Blue 400 */
    --primary-soft: #1e293b;
    /* Slate 800 (used for active states) */

    --bg-body: #0f172a;
    /* Slate 900 */
    --bg-surface: #1e293b;
    /* Slate 800 */
    --bg-surface-alt: #334155;
    /* Slate 700 */

    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #cbd5e1;
    /* Slate 300 */
    --text-light: #64748b;
    /* Slate 500 */

    --border-light: #334155;
    /* Slate 700 */
}

/* Base Typography */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Noto Naskh Arabic', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Layout */
.app-container {
    max-width: 800px;
    /* Reduced for better readability */
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid transparent;
    /* Placeholder */
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo span {
    color: var(--primary-color);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
    background: var(--bg-surface-alt);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Controls Panel - Floating Card Style */
.controls-panel {
    background: var(--bg-surface);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.25rem;
    align-items: end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
}

/* Custom Select */
select {
    appearance: none;
    background-color: var(--bg-surface-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    width: 100%;
    transition: var(--transition-fast);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: left 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-left: 2.5rem;
    /* Space for icon */
}

select:hover {
    border-color: var(--text-muted);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Toggles */
.toggle-group {
    display: flex;
    /* Override column layout for toggles */
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface-alt);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.toggle-group label:first-child {
    font-size: 0.85rem;
    color: var(--text-main);
    text-transform: none;
    font-weight: 500;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    position: relative;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-light);
    transition: var(--transition-fast);
    border-radius: var(--radius-full);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    right: 2px;
    bottom: 2px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
}

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

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

/* Stop Button */
.stop-btn {
    background-color: var(--bg-surface-alt);
    color: var(--error);
    border: 1px solid #fecaca;
    /* Light red border */
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    grid-column: 1 / -1;
    /* Full width on mobile */
}

[data-theme="dark"] .stop-btn {
    background-color: rgb(79 70 229 / 0.1);
    border-color: rgb(239 68 68 / 0.2);
}

.stop-btn:hover {
    background-color: var(--error);
    color: white;
    border-color: var(--error);
    transform: translateY(-1px);
}

/* Now Playing Bar - Glassmorphism feel */
.now-playing {
    position: sticky;
    top: 1rem;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    /* Blur effect */
    border: 1px solid var(--border-light);
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-smooth);
}

[data-theme="dark"] .now-playing {
    background: rgba(30, 41, 59, 0.9);
}

.now-playing.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.now-playing-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.now-playing-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    overflow: hidden;
}

.now-playing-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.now-playing-text {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bar-btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    padding: 0;
    flex-shrink: 0;
}

.bar-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

.bar-btn.stop-play {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: var(--error);
}

.bar-btn.stop-play:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.progress-bar {
    height: 6px;
    background-color: var(--bg-surface-alt);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.1s linear;
}

/* Tabs */
.tabs {
    display: flex;
    background-color: var(--bg-surface-alt);
    padding: 0.25rem;
    border-radius: var(--radius-lg);
    gap: 0.25rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background-color: var(--bg-surface);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Content Sections */
.tab-content {
    display: none;
    animation: slideUp 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    margin-bottom: 2rem;
    text-align: center;
}

.section-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.section-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Story Cards */
.stories-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.story-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition-fast);
}

.story-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.story-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-light);
}

.story-paragraph {
    font-size: 1.15rem;
    line-height: 2.2;
    /* Better readability for Arabic */
    text-align: justify;
}

.sentence-text {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sentence-text:hover {
    background-color: var(--primary-soft);
    color: var(--primary-color);
}

.sentence-text.playing {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 0 4px var(--primary-color);
    /* Highlight effect */
    border-radius: 2px;
}

/* Bullets & Words Unified Style */
.bullets-container,
.words-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.bullets-section,
.word-category {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.bullet-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bullet-list li,
.word-card {
    background: var(--bg-surface-alt);
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bullet-list li:hover,
.word-card:hover {
    background: var(--primary-soft);
    border-color: var(--primary-color);
    transform: translateX(-4px);
    /* Interactive movement */
}

/* Numbered bullets styling */
.bullet-list.numbered {
    counter-reset: item;
}

.bullet-list.numbered li::before {
    counter-increment: item;
    content: counter(item);
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Regular bullets */
.bullet-list:not(.numbered) li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.5rem;
    line-height: 1;
}

/* Words Grid */
.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.word-card {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
}

.word-card:hover {
    transform: translateY(-4px);
    /* Lift effect */
}

.word-arabic {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.word-translation {
    font-size: 0.825rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.word-card.playing,
.bullet-list li.playing {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.word-card.playing .word-translation,
.word-card.playing .word-arabic {
    color: white;
}

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

/* Responsive Adjustments */
@media (min-width: 640px) {
    .controls-panel {
        grid-template-columns: repeat(3, 1fr) auto;
        /* 3 controls + stop btn */
    }

    .stop-btn {
        grid-column: auto;
        /* Reset to auto width */
        width: auto;
    }
}