:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.5s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.main-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.1rem;
    color: var(--text-light);
}

.version-tag {
    font-size: 0.75rem;
    background: var(--border);
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    margin-top: 0.5rem;
    color: var(--text-light);
    font-weight: bold;
}

.subjects-grid {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.day-section {
    animation: fadeInDown 0.5s ease-out;
}

.day-title {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.subjects-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.subject-time {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 0.5rem;
}

.subject-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.subject-code {
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subject-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.file-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: right;
    transition: background 0.2s;
    font-family: inherit;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-item:hover {
    background: #e2e8f0;
    border-color: var(--primary);
}

.actions {
    display: flex;
    gap: 1rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: background 0.2s;
    text-align: center;
    flex: 1;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.pdf-viewer-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.hidden {
    display: none;
}

.viewer-header {
    background: white;
    padding: 1rem;
    border-radius: 1rem 1rem 0 0;
    display: grid;
    grid-template-areas:
        "close title"
        "actions actions";
    gap: 1rem;
    align-items: center;
}

#close-viewer {
    grid-area: close;
    justify-self: start;
    width: auto;
}

#viewer-title {
    grid-area: title;
    font-size: 1.1rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-actions {
    grid-area: actions;
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.pdf-container {
    flex: 1;
    background: #525659;
    border-radius: 0 0 1rem 1rem;
    overflow: hidden;
    position: relative;
}

#pdf-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.pwa-prompt {
    position: fixed;
    bottom: 2rem;
    left: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pwa-content h3 {
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-size: 1.25rem;
}

.pwa-content p {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-light);
}

.pwa-buttons {
    display: flex;
    gap: 0.75rem;
}

#ios-instructions {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    color: #ef4444;
    font-size: 0.9rem;
    line-height: 1.5;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 641px) {
    .viewer-header {
        grid-template-areas: "close title actions";
        grid-template-columns: auto 1fr auto;
        padding: 1rem 2rem;
    }

    #viewer-title {
        text-align: center;
        font-size: 1.25rem;
    }

    .viewer-actions {
        width: auto;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header {
        margin-bottom: 2rem;
    }

    .main-logo {
        width: 80px;
        height: 80px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    header p {
        font-size: 1rem;
    }

    .day-title {
        font-size: 1.25rem;
    }

    .subject-card {
        padding: 1.25rem;
    }

    .subject-name {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .file-item {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
}