/*********************************************************
 * Enhanced "Check" page with premium popup design
 * Responsive design with modern animations and styling
 *********************************************************/

/* Import Tajawal font from Google */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #0d6efd;
    --primary-dark: #0b5ed7;
    --success-color: #00C853;
    --success-dark: #00B140;
    --danger-color: #FF1744;
    --danger-light: #FF5252;
    --gold-color: #dabd44;
    --gold-light: #f6f1e3;
    --text-primary: #2c3e50;
    --text-secondary: #555;
    --text-muted: #666;
    --border-color: #ddd;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 10px 30px rgba(0, 0, 0, 0.3);
    --gradient-bg: linear-gradient(135deg, #fff 0%, #fefefe 100%);
    --border-radius: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    line-height: 1.6;
}

/* Style for the reload countdown */
#reload-countdown {
    background: linear-gradient(135deg, #78ffe5 0%, #4ecdc4 100%);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 700;
    font-size: 1rem;
    display: inline-block;
    box-shadow: var(--shadow-light);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

    #reload-countdown:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-medium);
    }

/* Container with enhanced styling */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    background: var(--gradient-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

    .container::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, var(--primary-color), var(--gold-color), var(--success-color));
    }

/* Navigation links */
.nav-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

    .nav-links a {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
        color: #fff;
        padding: 0.875rem 2rem;
        border-radius: 25px;
        text-decoration: none;
        font-weight: 600;
        transition: var(--transition);
        box-shadow: var(--shadow-light);
        border: none;
    }

        .nav-links a:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-medium);
        }

/* Enhanced heading */
h2 {
    text-align: center;
    font-size: 2.2rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    font-weight: 700;
    position: relative;
}

    h2::after {
        content: '';
        position: absolute;
        bottom: -10px;
        left: 50%;
        transform: translateX(-50%);
        width: 80px;
        height: 3px;
        background: linear-gradient(90deg, var(--primary-color), var(--gold-color));
        border-radius: 2px;
    }

/* Enhanced info bar with premium design */
.info-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #000000 100%);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

    .info-bar::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        pointer-events: none;
    }

    .info-bar div {
        font-size: 1rem;
        font-weight: 600;
        color: #ffffff;
        text-align: center;
        padding: 1rem 1.5rem;
        border-radius: 15px;
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        transition: var(--transition);
        position: relative;
        z-index: 1;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }

        .info-bar div:hover {
            background: rgba(255, 255, 255, 0.25);
            transform: translateY(-3px) scale(1.02);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
        }

/* Individual styling for each info item */
#day-name {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 142, 83, 0.2));
    border-left: 4px solid #ff6b6b;
}

#miladi-date {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.2), rgba(80, 227, 194, 0.2));
    border-left: 4px solid #4a90e2;
}

#hijri-date {
    background: linear-gradient(135deg, rgba(126, 87, 194, 0.2), rgba(171, 71, 188, 0.2));
    border-left: 4px solid #7e57c2;
}

#server-time {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 152, 0, 0.2));
    border-left: 4px solid #ffc107;
}

#reload-countdown {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3), rgba(129, 199, 132, 0.3));
    border-left: 4px solid #4caf50;
    border-radius: 20px;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* Enhanced table styling */
.check-table {
    width: 100%;
    margin: 2rem auto;
    border-collapse: collapse;
    text-align: center;
    font-size: 1.1rem;
    background: #fff;
    border: 3px solid var(--gold-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    table-layout: fixed;
}

    .check-table thead {
        background: linear-gradient(135deg, var(--gold-light) 0%, #f0e68c 100%);
        font-weight: 700;
        color: var(--text-primary);
    }

    .check-table th,
    .check-table td {
        border: 1px solid var(--gold-color);
        padding: 1rem 0.75rem;
        vertical-align: middle;
        transition: var(--transition);
    }

    .check-table th {
        font-size: 1.2rem;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }

    .check-table td.disabled {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        color: #999;
        font-style: italic;
    }

    .check-table tbody tr:hover td:not(.disabled) {
        background: rgba(13, 110, 253, 0.05);
    }

/* Grade name styling */
.grade-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Column widths */
.check-table thead th:first-child,
.check-table tbody td:first-child {
    width: 20%;
}

.check-table thead th:not(:first-child),
.check-table tbody td:not(:first-child) {
    width: 26.666%;
}

/* Enhanced subgrid container */
.subgrid-container {
    display: grid;
    grid-template-rows: auto min-content;
    align-items: start;
    justify-items: center;
    max-width: 120px;
    margin: 0 auto;
    width: 100%;
}

/* Enhanced period subgrid */
.period-subgrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    padding: 4px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

/* Enhanced period boxes */
.period-box {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    border-radius: 4px;
    transition: var(--transition);
    aspect-ratio: 1 / 1;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

    .period-box::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
        transition: left 0.5s;
    }

    .period-box:hover::before {
        left: 100%;
    }

.filled-box {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.missing-box {
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-light) 100%);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.period-box:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: var(--shadow-medium);
    z-index: 1;
}

/* Enhanced leader info */
.leader-info {
    margin: 0.5rem auto 0;
    font-size: 0.75rem;
    line-height: 1.2;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 120px;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
}

/* Message styling */
.message {
    text-align: center;
    font-weight: 600;
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
}

    .message.error {
        color: var(--danger-color);
        background: rgba(255, 23, 68, 0.1);
        border: 1px solid rgba(255, 23, 68, 0.2);
    }

    .message.success {
        color: var(--success-color);
        background: rgba(0, 200, 83, 0.1);
        border: 1px solid rgba(0, 200, 83, 0.2);
    }

/* ===== PREMIUM POPUP STYLES ===== */
.popup-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    padding: 1rem;
}

.popup-content {
    background: #fff;
    border-radius: 20px;
    padding: 0;
    min-width: 320px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-heavy);
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    position: relative;
}

    .popup-content::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, var(--primary-color), var(--gold-color), var(--success-color));
    }

#popup-title {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 1.5rem 2rem;
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

#popup-body {
    padding: 0;
    max-height: 60vh;
    overflow-y: auto;
}

.popup-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    cursor: pointer;
    font-size: 24px;
    font-weight: 700;
    color: #999;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    z-index: 1;
}

    .popup-close:hover {
        background: rgba(255, 0, 0, 0.1);
        color: var(--danger-color);
        transform: scale(1.1);
    }

/* Homework container styles */
.homework-container {
    padding: 1.5rem;
}

.leader-section {
    margin-bottom: 1.5rem;
    text-align: center;
}

.leader-name {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
    border: 2px solid rgba(13, 110, 253, 0.1);
    display: inline-block;
    box-shadow: var(--shadow-light);
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.current-homework-section {
    margin-bottom: 2rem;
}

.historical-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.homework-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
}

    .homework-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-medium);
    }

    .homework-card.current {
        border-left: 4px solid var(--success-color);
        background: linear-gradient(135deg, #ffffff 0%, rgba(0, 200, 83, 0.02) 100%);
    }

    .homework-card.historical {
        border-left: 4px solid var(--primary-color);
        background: linear-gradient(135deg, #ffffff 0%, rgba(13, 110, 253, 0.02) 100%);
    }

.homework-field {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
}

    .homework-field strong {
        color: var(--text-primary);
        font-weight: 600;
        margin-left: 0.5rem;
    }

.homework-text {
    background: rgba(0, 0, 0, 0.02);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.date-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    margin-top: 1rem;
}

.no-data-message {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.error-message {
    text-align: center;
    padding: 1.5rem;
    color: var(--danger-color);
    background: rgba(255, 23, 68, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 23, 68, 0.2);
}

/* Loading styles */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Popup animations */
.popup-animate-in {
    animation: popupSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.popup-animate-out {
    animation: popupSlideOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes popupSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    to {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
}

/* Footer */
.footer {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 2rem 0 1rem;
    border-top: 1px solid var(--border-color);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .container {
        margin: 1rem;
        padding: 1.5rem;
    }

    .info-bar {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .check-table {
        font-size: 1rem;
    }

        .check-table th,
        .check-table td {
            padding: 0.75rem 0.5rem;
        }

    .period-box {
        font-size: 0.8rem;
    }

    .leader-info {
        font-size: 0.7rem;
        max-width: 100px;
    }

    h2 {
        font-size: 1.8rem;
    }

    .popup-content {
        min-width: 280px;
        max-width: 95%;
    }

    .homework-container {
        padding: 1rem;
    }

    #popup-title {
        font-size: 1.2rem;
        padding: 1rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 0.5rem;
        padding: 1rem;
    }

    .nav-links {
        flex-direction: column;
        gap: 1rem;
    }

        .nav-links a {
            padding: 0.75rem 1.5rem;
        }

    .info-bar div {
        font-size: 0.9rem;
        padding: 0.75rem 0.5rem;
    }

    .check-table {
        font-size: 0.95rem;
        overflow-x: auto;
    }

        .check-table th,
        .check-table td {
            padding: 0.5rem 0.25rem;
        }

    h2 {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }

    .subgrid-container {
        max-width: 90px;
    }

    .period-box {
        font-size: 0.75rem;
    }

    .leader-info {
        font-size: 0.65rem;
        max-width: 90px;
    }

    .popup-content {
        min-width: 250px;
        max-width: 98%;
        border-radius: 15px;
    }

    #popup-title {
        font-size: 1.1rem;
        padding: 1rem;
    }

    .homework-container {
        padding: 0.75rem;
    }

    .section-title {
        font-size: 1.1rem;
    }

    .homework-card {
        padding: 1rem;
    }

    .homework-field {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
}

/* Print styles */
@media print {
    .popup-modal,
    .nav-links,
    #reload-countdown {
        display: none !important;
    }

    .container {
        box-shadow: none;
        margin: 0;
        padding: 1rem;
    }

    .check-table {
        border: 2px solid #000;
    }

    .period-box {
        border: 1px solid #000;
        color: #000 !important;
    }

    .filled-box {
        background: #ccc !important;
    }

    .missing-box {
        background: #666 !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
        --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.4);
    }

    .period-box {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .period-box:hover {
        transform: none;
    }
}
