:root {
    --bg-color: #0f111a;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
                      radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.1), transparent 40%);
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    margin-bottom: 40px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

h1 span {
    color: var(--accent-color);
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 20px;
    font-weight: 500;
    transition: color 0.3s ease;
}

nav a:hover, nav a.active {
    color: var(--text-primary);
}

.player-section {
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.book-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.book-cover {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--accent-color), #ec4899);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

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

.book-details h2 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.status {
    color: var(--accent-color);
    font-size: 0.9rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-block;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--accent-color);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.primary-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    box-shadow: none;
}

.progress-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    width: 45px;
}

.progress-bar-wrapper {
    flex-grow: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.ai-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(99, 102, 241, 0.3);
    width: 0%;
    transition: width 0.3s linear;
}

.play-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.1s linear;
}

.debug-info {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: -10px;
}

select option, select optgroup {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* CATEGORY BROWSER STYLES */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}
.category-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
}
.category-card:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
    border-color: var(--accent-color);
}
.category-name {
    font-weight: 600;
    margin-bottom: 5px;
}
.category-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* RESPONSIVE DESIGN (MOBILE) */
@media (max-width: 768px) {
    .app-container {
        padding: 10px;
    }
    header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        text-align: center;
    }
    nav {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    nav span {
        margin-right: 0 !important;
    }
    nav a {
        margin-left: 0;
    }
    .tabs {
        flex-direction: column;
    }
    .tabs button {
        width: 100% !important;
    }
    #section-chitanka > div:first-child,
    .upload-form {
        flex-direction: column;
        align-items: stretch !important;
    }
    #section-chitanka > div:first-child > div,
    #section-chitanka > div:first-child > input,
    #section-chitanka > div:first-child > button,
    .upload-form > input,
    .upload-form > div,
    .upload-form > button {
        width: 100% !important;
    }
    .books-grid {
        grid-template-columns: 1fr;
    }
    #chitanka-results {
        grid-template-columns: 1fr !important;
    }
    .categories-grid {
        grid-template-columns: 1fr 1fr;
    }
    .player-section {
        padding: 20px;
        width: 95% !important;
    }
    .book-info {
        flex-direction: column;
        text-align: center;
    }
    .book-details h2 {
        font-size: 1.5rem;
    }
}

/* Form Inputs for Glassmorphism UI */
.auth-input, .file-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
    height: 45px;
}

.auth-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.auth-input:focus, .file-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5); /* Primary color */
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

select.auth-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Specific styling for file inputs to make them look good in webkit */
.file-input {
    padding: 8px;
    cursor: pointer;
}

.file-input::-webkit-file-upload-button {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    border-radius: 6px;
    margin-right: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 500;
}

.file-input::-webkit-file-upload-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Voice Selector Modal Styles */
.voice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
}

.voice-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.voice-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.voice-icon {
    font-size: 2rem;
    flex-shrink: 0;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.voice-info h4 {
    margin: 0 0 4px 0;
    font-size: 1.05rem;
    color: #fff;
}

.voice-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.play-demo-btn {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #fff;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 0.9rem;
}

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

.voice-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.select-voice-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    white-space: nowrap;
}

.voice-card {
    /* remove cursor: pointer and hover transform from the whole card since now buttons have their own roles */
    cursor: default;
}
.voice-card:hover {
    transform: none;
}
