:root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --accent: #0a84ff;
    --accent-light: #5da9ff;
    --separator: rgba(255, 255, 255, 0.16);
    --success: #4CAF50;
    --error: #FF4444;
    --radius: 14px;
    --radius-sm: 8px;
}

[data-theme="light"] {
    --bg: #ffffff;
    --surface: rgba(231, 231, 231, 0.467);
    --text: rgba(0, 0, 0, 0.92);
    --text-secondary: rgba(0, 0, 0, 0.6);
    --separator: rgba(0, 0, 0, 0.12);
    --accent-light: #4d9fff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 2rem;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 1rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.app-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.icon-button {
    background: var(--surface);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button:hover {
    transform: scale(1.08);
}

.theme-toggle {
    background: var(--surface);
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.verse-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 0.5px solid var(--separator);
    position: relative;
}

.verse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.favorite-btn {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.favorite-btn.active {
    color: var(--error);
}

.reference-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.arabic-text {
    font-family: 'Noto Naskh Arabic', 'Arial', 'Tahoma', serif;
    font-size: clamp(1.8rem, 6vw, 2.4rem);
    line-height: 2.2;
    direction: rtl;
    text-align: right;
    font-variant-ligatures: common-ligatures;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.3px;
    word-spacing: -2px;
    margin-bottom: 1.5rem;
}

.translation-text {
    color: var(--text);
    line-height: 1.6;
    padding: 1rem 0;
    border-top: 0.5px solid var(--separator);
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.ios-button {
    background: var(--surface);
    color: var(--accent);
    border: none;
    padding: 1rem;
    border-radius: var(--radius);
    width: 100%;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ios-button:active {
    opacity: 0.8;
}

.secondary {
    background: var(--surface) !important;
    color: var(--text-secondary) !important;
}

.history-section, .favorites-section {
    margin-top: 1rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-section.visible, .favorites-section.visible {
    max-height: 1000px;
    opacity: 1;
    margin-top: 2rem;
}

.history-title, .favorites-title {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.history-list, .favorites-list {
    display: grid;
    gap: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.history-item, .favorite-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 0.5px solid var(--separator);
    animation: slideIn 0.3s ease;
    position: relative;
}

.history-header, .favorite-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.history-index, .favorite-index {
    color: var(--accent);
    font-weight: 500;
}

.history-arabic, .favorite-arabic {
    font-family: 'Noto Naskh Arabic', 'Arial', 'Tahoma', serif;
    font-size: 1.4rem;
    text-align: right;
    direction: rtl;
    margin: 0.5rem 0;
}

.history-translation, .favorite-translation {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.fonts-loaded .arabic-text {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(var(--bg), 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    z-index: 100;
}

.activity-indicator {
    width: 32px;
    height: 32px;
    border: 3px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Audio Player Styles */
.audio-player {
    margin-top: 1.5rem;
    border-top: 0.5px solid var(--separator);
    padding-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.audio-control {
    background: var(--accent);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.progress-container {
    flex: 1;
    height: 4px;
    background: var(--separator);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.time-display {
    min-width: 40px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100px;
}

.volume-control i {
    color: var(--text-secondary);
}

.volume-control input {
    width: 100%;
    accent-color: var(--accent);
}

.favorite-item .favorite-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.favorite-play {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 36px;
}

.favorite-remove {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--separator);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    min-height: 36px;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideUp {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@media (max-width: 600px) {
    .arabic-text {
        font-size: 1.8rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    .audio-player {
        flex-wrap: wrap;
    }
    
    .progress-container {
        order: 3;
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .volume-control {
        width: auto;
        flex: 1;
    }
}

.verse-text, .verse-translation, .verse-reference {
    opacity: 0;
    transition: opacity 0.5s ease-in;
}
.verse-card.loaded .verse-text,
.verse-card.loaded .verse-translation,
.verse-card.loaded .verse-reference {
    opacity: 1;
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.audio-control.playing {
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.error-notification {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.success-notification {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}
