@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

* {
    font-family: 'Cairo', sans-serif;
}

body {
    transition: background-color 0.3s, color 0.3s;
}

.dark {
    background-color: #1a202c;
    color: #e2e8f0;
}

/* ===== Cards ===== */
.card {
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* ===== Loader ===== */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Audio Player ===== */
.audio-player {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

/* ===== Favorite Icon ===== */
.favorite-icon {
    transition: all 0.3s;
}

.favorite-icon.active {
    fill: #ef4444;
    stroke: #ef4444;
}

/* ===== Range Input (Progress Bar) ===== */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
}

input[type="range"]::-webkit-slider-track {
    background: #cbd5e0;
    height: 4px;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background-color: #3b82f6;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    margin-top: -6px;
    cursor: pointer;
}

input[type="range"]::-moz-range-track {
    background: #cbd5e0;
    height: 4px;
    border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
    background-color: #3b82f6;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.dark input[type="range"]::-webkit-slider-track {
    background: #4a5568;
}

.dark input[type="range"]::-moz-range-track {
    background: #4a5568;
}

/* ===== Dropdown ===== */
.dropdown-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.dropdown-content.open {
    max-height: 500px;
    transition: max-height 0.5s ease-in;
}

.dropdown-arrow {
    transition: transform 0.3s;
}

.dropdown-arrow.open {
    transform: rotate(180deg);
}

/* ===== Reader Item ===== */
.reader-item {
    transition: all 0.2s;
}

.reader-item:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.dark .reader-item:hover {
    background-color: rgba(59, 130, 246, 0.2);
}

/* ===== Animations ===== */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* ===== Line Clamp ===== */
.line-clamp-1 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.line-clamp-2 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===== Tabs Styles ===== */
.tab-btn {
    color: #6b7280;
    position: relative;
    transition: all 0.3s;
}

.dark .tab-btn {
    color: #9ca3af;
}

.tab-btn:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

.dark .tab-btn:hover {
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.1);
}

.tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

.dark .tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.1);
}

/* ===== Latmiyat Card Specific Styles ===== */
.latmiyat-card {
    position: relative;
}

.latmiyat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #a855f7);
}

.latmiyat-card .dropdown-toggle {
    display: none;
}

.latmiyat-card .dropdown-content {
    display: none;
}

.latmiyat-card .play-btn {
    width: 100%;
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    transition: all 0.3s;
}

.latmiyat-card .play-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #9333ea);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.latmiyat-card .play-btn:active {
    transform: translateY(0);
}

/* ===== Badge Styles ===== */
.badge-latmiya {
    background: linear-gradient(135deg, #8b5cf6, #a855f7);
    backdrop-filter: blur(10px);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.dark ::-webkit-scrollbar-track {
    background: #2d3748;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4a5568;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Scrollbar for dropdowns */
.dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.dropdown-content::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.dark .dropdown-content::-webkit-scrollbar-thumb {
    background: #4a5568;
}

/* ===== Table Styles ===== */
table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
}

.dark table tbody tr {
    border-bottom-color: #374151;
}

table tbody tr:hover {
    background-color: #f9fafb;
}

.dark table tbody tr:hover {
    background-color: #374151;
}

table thead {
    background: #f3f4f6;
}

.dark table thead {
    background: #374151;
}

/* ===== Chart Container ===== */
canvas {
    max-height: 400px;
}

/* ===== Notification ===== */
.notification {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 300px;
    max-width: 500px;
    animation: slideDown 0.3s ease-out;
    transition: all 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Loading Skeleton ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .audio-player {
        padding: 0.75rem;
    }

    #playerTitle {
        font-size: 0.875rem;
    }

    #playerReader {
        font-size: 0.75rem;
    }

    .audio-player img {
        width: 3rem;
        height: 3rem;
    }

    .audio-player button {
        padding: 0.5rem;
    }
    
    .tab-btn {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 640px) {
    .notification {
        min-width: 250px;
        max-width: 90%;
        font-size: 0.875rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    header, 
    .audio-player, 
    button, 
    .tab-btn,
    input[type="text"],
    input[type="range"],
    select {
        display: none !important;
    }

    .container {
        max-width: 100%;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* ===== Smooth Transitions ===== */
.card,
.latmiyat-card,
button,
.tab-btn,
input,
select {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Focus Styles ===== */
button:focus,
input:focus,
select:focus {
    outline: none;
    ring: 2px;
    ring-color: #3b82f6;
}

.dark button:focus,
.dark input:focus,
.dark select:focus {
    ring-color: #60a5fa;
}

/* ===== Disabled State ===== */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Statistics Page Specific ===== */
.stats-card {
    transition: all 0.3s;
}

.stats-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* ===== Gradient Text ===== */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Pulse Animation ===== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ===== Utility Classes ===== */
.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.shadow-glow {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.dark .shadow-glow {
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.3);
}