﻿:root {
    /* Light theme colors */
    --primary-color: #2c5530;
    --primary-hover: #1e3a21;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    
    /* Background colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-card: #ffffff;
    --bg-card-elevated: #ffffff;
    --bg-hover: #f1f3f4;
    
    /* Text colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #8e9297;
    --text-arabic: #2c3e50;
    --text-transliteration: #7f8c8d;
    
    /* Border colors */
    --border-color: #e5e7eb;
    --border-focus: rgba(44, 85, 48, 0.25);
    
    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Spacing */
    --border-radius: 0.75rem;
    --border-radius-lg: 1rem;
    
    /* Navigation */
    --nav-bg: #ffffff;
    --nav-text: #212529;
    --nav-hover: rgba(44, 85, 48, 0.08);
    
    /* Modal/Overlay */
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --modal-backdrop: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    /* Dark theme colors */
    --primary-color: #4ade80;
    --primary-hover: #22c55e;
    --secondary-color: #6b7280;
    
    /* Background colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-card-elevated: #334155;
    --bg-hover: #475569;
    
    /* Text colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-arabic: #f1f5f9;
    --text-transliteration: #94a3b8;
    
    /* Border colors */
    --border-color: #334155;
    --border-focus: rgba(74, 222, 128, 0.25);
    
    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    
    /* Navigation */
    --nav-bg: #1e293b;
    --nav-text: #f1f5f9;
    --nav-hover: rgba(74, 222, 128, 0.1);
    
    /* Modal/Overlay */
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --modal-backdrop: rgba(0, 0, 0, 0.5);
}

/* Base styles */
* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
}

    h1:focus {
        outline: none;
    }

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

    a:hover {
        color: var(--primary-hover);
    }

/* Layout - Fixed for mobile responsiveness */
.app-layout {
    display: block;
    min-height: 100vh;
    background-color: var(--bg-primary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    /* Remove margin-left on mobile, add it only on desktop */
    margin-left: 0;
}

.content-container {
    flex: 1;
    padding: 1rem;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    user-select: none;
}

    .btn:focus {
        outline: 2px solid var(--border-focus);
        outline-offset: 2px;
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none !important;
    }

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

    .btn-primary:hover:not(:disabled) {
        background-color: var(--primary-hover);
        transform: translateY(-1px);
    }

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

    .btn-outline-primary:hover:not(:disabled) {
        background-color: var(--primary-color);
        color: white;
    }

/* Form controls */
.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

    .form-control:focus {
        outline: 0;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px var(--border-focus);
    }

/* Install Prompt Modal Styles */
.install-prompt {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-card-elevated);
    color: var(--text-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    padding: 2rem;
    max-width: 90vw;
    width: 400px;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

    .install-prompt::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--modal-overlay);
        z-index: -1;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .install-prompt.show {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, -50%) scale(1);
    }

        .install-prompt.show::before {
            opacity: 1;
        }

    .install-prompt h3,
    .install-prompt strong {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0 0 0.75rem 0;
        line-height: 1.3;
    }

    .install-prompt p,
    .install-prompt div:not(:last-child) {
        color: var(--text-secondary);
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }

    .install-prompt div:last-child {
        margin-bottom: 0;
    }

    /* Install prompt buttons */
    .install-prompt button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        border: none;
        border-radius: var(--border-radius);
        font-weight: 600;
        font-size: 0.875rem;
        cursor: pointer;
        transition: all 0.2s ease;
        text-decoration: none;
        user-select: none;
        min-height: 2.75rem;
    }

        .install-prompt button:first-of-type {
            background: var(--primary-color);
            color: white;
            margin-right: 0.75rem;
        }

            .install-prompt button:first-of-type:hover {
                background: var(--primary-hover);
                transform: translateY(-1px);
            }

        .install-prompt button:last-of-type,
        .install-prompt button:only-of-type {
            background: transparent;
            color: var(--text-secondary);
            border: 1px solid var(--border-color);
        }

            .install-prompt button:last-of-type:hover,
            .install-prompt button:only-of-type:hover {
                background: var(--bg-secondary);
                color: var(--text-primary);
                border-color: var(--primary-color);
            }

        .install-prompt button:focus {
            outline: 2px solid var(--border-focus);
            outline-offset: 2px;
        }

    /* Install prompt icon */
    .install-prompt::after {
        content: '📱';
        position: absolute;
        top: -1rem;
        left: 50%;
        transform: translateX(-50%);
        font-size: 2rem;
        background: var(--bg-card-elevated);
        width: 3rem;
        height: 3rem;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 3px solid var(--primary-color);
        box-shadow: var(--shadow-lg);
    }

    /* Different styles for different install scenarios */
    .install-prompt.manual-install::after {
        content: '💡';
    }

    .install-prompt.auto-install::after {
        content: '⬇️';
    }

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Validation */
.valid.modified:not([type=checkbox]) {
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
}

.invalid {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.validation-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* PWA and error handling */
#blazor-error-ui {
    background: var(--danger-color);
    bottom: 0;
    box-shadow: var(--shadow-lg);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
    font-weight: 500;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 1rem;
        top: 0.5rem;
        color: white;
        text-decoration: none;
        font-size: 1.5rem;
        line-height: 1;
    }

.blazor-error-boundary {
    background: var(--danger-color);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--border-radius);
    margin: 1rem 0;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--border-color);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--primary-color);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--text-primary);
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* Code styling */
code {
    color: var(--primary-color);
    background-color: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, 'Courier New', monospace;
    font-size: 0.875em;
}

/* Responsive utilities - Fixed mobile layout */
@media (max-width: 767.98px) {
    .content-container {
        padding: 0.5rem;
    }

    /* Mobile install prompt adjustments */
    .install-prompt {
        width: 95vw;
        padding: 1.5rem;
        margin: 1rem;
    }

        .install-prompt button {
            width: 100%;
            margin: 0.25rem 0;
        }

            .install-prompt button:first-of-type {
                margin-right: 0;
                margin-bottom: 0.5rem;
            }
}

@media (min-width: 768px) {
    .app-layout {
        display: flex;
    }

    .main-content {
        margin-left: 280px;
    }

    .content-container {
        padding: 2rem;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .install-prompt,
    .install-prompt::before {
        transition: none;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .nav-container,
    .verse-navigation,
    .action-section,
    .install-prompt {
        display: none !important;
    }

    .verse-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .install-prompt {
        border: 2px solid var(--text-primary);
    }

        .install-prompt button {
            border: 2px solid currentColor;
        }
}

/* Dark mode specific adjustments for install prompt */
[data-theme="dark"] .install-prompt {
    background: var(--bg-card-elevated);
    border-color: var(--border-color);
}

    [data-theme="dark"] .install-prompt::after {
        background: var(--bg-card-elevated);
        border-color: var(--primary-color);
    }

/* Animation for install prompt entrance */
@keyframes installPromptSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) translateY(2rem);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
}

.install-prompt.show {
    animation: installPromptSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}
