@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&display=swap');

:root {
    --primary-color: #fefffb;
    --secondary-color: #aac65d;
    --accent-color: #137980;
    --white: #ffffff;
    --light-gray: #f7f7f7;
    --dark-gray: #d5e0eb;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
}

[data-theme="dark"] {
    --primary-color: #1a1a1a;
    --secondary-color: #8ba83f;
    --accent-color: #4a9ba5;
    --white: #2d2d2d;
    --light-gray: #333333;
    --dark-gray: #555555;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--light-gray);
    color: var(--accent-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
}

.header {
    background: var(--primary-color);
    height: 70px;
    padding: 0 2rem;
    border-bottom: 2px solid var(--accent-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-button {
    background: none;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    text-decoration: none;
}

.back-button:hover {
    background: var(--accent-color);
    color: var(--primary-color);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
}

.theme-toggle:hover {
    background: var(--accent-color);
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1rem;
    overflow: hidden;
    border: 2px solid var(--accent-color);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.main-content {
    padding: 2rem;
}

/* Controls Section */
.controls-section {
    background: var(--white);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

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

.controls-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--accent-color);
    font-weight: 700;
}

.view-toggle {
    display: flex;
    background: var(--light-gray);
    border-radius: 8px;
    padding: 0.3rem;
}

.view-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--accent-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    font-family: 'Tajawal', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    font-weight: 600;
    color: var(--accent-color);
    font-size: 0.9rem;
}

.filter-select, .filter-input {
    padding: 0.7rem;
    border: 2px solid var(--dark-gray);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    background: var(--white);
    color: var(--accent-color);
    transition: border-color 0.3s ease;
    font-size: 0.9rem;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.filter-actions {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 0.7rem 0.7rem 0.7rem 2.5rem;
    border: 2px solid var(--dark-gray);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    background: var(--white);
    color: var(--accent-color);
    transition: border-color 0.3s ease;
}

.search-icon {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.btn {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

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

.btn-primary:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

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

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Folder Navigation */
.folder-nav {
    background: var(--white);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

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

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.breadcrumb-item {
    color: var(--accent-color);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
}

.breadcrumb-item:hover {
    background: var(--light-gray);
}

.breadcrumb-item.active {
    background: var(--secondary-color);
    color: var(--white);
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.folder-item {
    background: var(--light-gray);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    border: 2px solid transparent;
}

.folder-item:hover {
    background: var(--secondary-color);
    color: var(--white);
    transform: translateY(-3px);
}

.folder-item.custom {
    border-color: var(--info-color);
}

.folder-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.folder-item:hover .folder-icon {
    color: var(--white);
}

.folder-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.folder-count {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.2rem;
}

/* Files Container */
.files-container {
    background: var(--white);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

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

.section-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--accent-color);
    font-size: 1.3rem;
    font-weight: 700;
}

.files-count {
    background: var(--secondary-color);
    color: var(--white);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Grid View */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* The thumbnail box. These properties were written inline by
   js/student/student-videos.js on every card; only the background-image and the
   cursor still are. Keeping them here is what lets the mobile block below swap
   the fixed height for an aspect ratio — an inline style would win over it. */
.file-card-header {
    position: relative;
    min-height: 180px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.file-card {
    background: var(--light-gray);
    border-radius: 12px;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.file-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: var(--secondary-color);
    transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease, box-shadow 0.5s ease, transform 0.5s ease, opacity 0.5s ease, filter 0.5s ease;
}

.file-thumbnail {
    width: 100%;
    height: 160px;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 3rem;
    position: relative;
    overflow: hidden;
}

.file-thumbnail img, .file-thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-type-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.7);
    color: var(--white);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: var(--white);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.file-card:hover .play-overlay {
    opacity: 1;
}

.file-info {
    padding: 1rem;
}

.file-title {
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    line-height: 1.3;
}

.file-meta {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.file-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

.file-meta-item i {
    width: 12px;
    text-align: center;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

/* List View */
.files-list {
    display: none;
}

.files-list.active {
    display: block;
}

.files-grid.active {
    display: grid;
}

.files-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.files-table th, .files-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--dark-gray);
}

.files-table th {
    background: var(--light-gray);
    font-weight: 600;
    color: var(--accent-color);
}

.files-table tr:hover {
    background: var(--light-gray);
}

.file-name-cell {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--secondary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.2rem;
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 0.2rem;
}

.file-description {
    font-size: 0.85rem;
    color: #666;
}

/* No files state */
.no-files {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.no-files i {
    font-size: 5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .header {
        padding: 0 1rem;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .controls-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .view-toggle {
        align-self: center;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .search-box {
        max-width: none;
    }

    .folder-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Two cards per row on a phone.
     *
     * This used to be a single full-width column, which turned every card into
     * a tall rectangle: a 180px thumbnail, a title, a description and three meta
     * rows stacked down a 350px-wide card. Halving the width alone would make
     * that worse, so the whole card is compacted with it — the thumbnail becomes
     * a 16:9 box that scales with the column, and the text below is clamped.
     */
    .files-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.85rem;
    }

    /* Grid stretches both cards in a row to the taller one; without this the
       shorter card's buttons float mid-card instead of lining up with its
       neighbour's. */
    .file-card {
        display: flex;
        flex-direction: column;
    }

    .file-card .file-actions {
        margin-top: auto;
    }

    .file-card-header {
        /* Scales with the column instead of pinning a height a half-width card
           cannot fill sensibly. min-height must be cleared for it to apply. */
        aspect-ratio: 16 / 9;
        min-height: 0;
    }

    /* The text block has no padding of its own at any width — it sits flush
       against the card edge. At half width that reads as cramped, so the inset
       is added here rather than changing how the desktop card looks. */
    .file-info-below {
        padding: 0.6rem 0.6rem 0;
    }

    .file-title {
        font-size: 0.9rem;
        line-height: 1.35;
        /* Two lines, then ellipsis — otherwise one long title alone decides how
           tall the row is, and its neighbour is padded out to match. */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .file-description {
        font-size: 0.78rem;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .file-meta {
        gap: 0.15rem;
        margin-bottom: 0.6rem;
        padding: 0 0.6rem;
    }

    .file-meta .meta-item,
    .file-meta-item {
        font-size: 0.72rem;
        gap: 0.3rem;
    }

    .file-actions {
        padding: 0 0.6rem 0.6rem;
        gap: 0.35rem;
    }

    .file-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 0.4rem 0.3rem;
        font-size: 0.75rem;
    }

    .user-info span {
        display: none;
    }

    .files-table {
        font-size: 0.9rem;
    }

    .files-table th, .files-table td {
        padding: 0.5rem;
    }
}

/* "Available in the app only" note on a platform-restricted item */
.platform-blocked-note {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.3rem;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #b45309;
}

.platform-blocked-note i {
    color: #b45309;
}

[data-theme="dark"] .platform-blocked-note,
[data-theme="dark"] .platform-blocked-note i {
    color: #fbbf24;
}

@media (max-width: 480px) {
    /* Folders stay two-up like the cards above them — a single full-width
       folder next to a two-column file grid reads as a broken page. */
    .folder-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.85rem;
    }

    .files-grid {
        gap: 0.6rem;
    }

    /* The actions no longer stack: at two cards per row they are already
       compact, and stacking them was part of what made the card so tall. */
    .file-actions {
        flex-direction: row;
    }

    .breadcrumb {
        flex-wrap: wrap;
    }
}

/**/
/**/

