/* ============================================
   DOWNLOADS PAGE STYLES
   ============================================ */

/* ---------- OVERLAY ---------- */
.downloads-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: var(--bg-primary);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
    will-change: transform, opacity;
}

.downloads-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}



/* Content wrapper */
.downloads-overlay-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--bg-primary) 30%,
        var(--bg-primary) 100%
    );
}

/* ---------- TOP BAR ---------- */
.downloads-top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: calc(var(--safe-top) + 8px) 16px 8px 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.downloads-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

.downloads-back-btn:hover {
    background-color: var(--bg-hover);
}

.downloads-back-btn:active {
    background-color: var(--bg-active);
}

.downloads-back-btn .material-icons-round {
    font-size: 2rem;    color: var(--text-primary);
    pointer-events: none;
}

.downloads-top-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ---------- SCROLLABLE CONTENT ---------- */
.downloads-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 32px 24px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* ---------- STORAGE INFO ---------- */
.downloads-storage {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--divider-color);
    border-radius: 12px;
    margin-bottom: 24px;
}

.storage-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    background: var(--accent-light);
    flex-shrink: 0;
}

.storage-icon .material-icons-round {
    font-size: 2rem;    color: var(--accent-color);
}

.storage-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.storage-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.storage-size {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.storage-clear-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.storage-clear-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.storage-clear-btn .material-icons-round {
    font-size: 1.5rem;    pointer-events: none;
}

.storage-clear-label {
    pointer-events: none;
}

/* ---------- DOWNLOADS LIST ---------- */
.downloads-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Download item */
.download-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--divider-color);
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    font-family: 'Poppins', sans-serif;
}

.download-item:last-child {
    border-bottom: none;
}

.download-item:hover {
    background: var(--bg-surface-light);
}

.download-item:active {
    background: var(--bg-hover);
}

/* Download icon */
.download-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 8px;
    flex-shrink: 0;
}

.download-item-icon .material-icons-round {
    font-size: 1.875rem;    color: #ffffff;
    pointer-events: none;
}

/* Download info */
.download-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.download-item-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    pointer-events: none;
}

.download-item-subject {
    font-size: .9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.download-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    flex-wrap: wrap;
    pointer-events: none;
}

.download-item-meta .meta-divider {
    width: 3px;
    height: 3px;
    background: var(--text-tertiary);
    border-radius: 50%;
    flex-shrink: 0;
}

/* Type badge */
.download-item-type {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    pointer-events: none;
}

.download-item-type.quiz {
    background: var(--accent-light);
    color: var(--accent-color);
}

.download-item-type.material {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
}

/* Delete button */
.download-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.download-item-delete:hover {
    background: var(--bg-active);
    color: var(--accent-color);
}

.download-item-delete .material-icons-round {
    font-size: 1.625rem;    pointer-events: none;
}

/* ---------- LOADING STATE ---------- */
.downloads-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px;
    color: var(--text-secondary);
}

.downloads-loading .material-icons-round {
    font-size: 3.5rem;    color: var(--accent-color);
    animation: pulse 1.5s ease infinite;
}

/* ---------- EMPTY STATE ---------- */
.downloads-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px;
    color: var(--text-secondary);
    text-align: center;
}

.downloads-empty .material-icons-round {
    font-size: 3.5rem;    color: var(--text-disabled);
}

.downloads-empty p {
    color: var(--text-secondary);
}

/* ---------- DESKTOP LAYOUT ---------- */
@media (min-width: 711px) {
    .downloads-scroll {
        margin: 0 auto;
        width: 100%;
        padding: 0 48px 32px 48px;
    }
    
    .download-item {
        padding: 16px 8px;
        border-radius: 8px;
    }
    
    .download-item:hover {
        padding-left: 12px;
    }
    
    .download-item-icon {
        width: 52px;
        height: 52px;
        min-width: 52px;
    }
    
    .download-item-icon .material-icons-round {
        font-size: 2.125rem;    }
    
    .download-item-title {
        font-size: 1.1rem;
    }
}

/* ---------- MOBILE RESPONSIVE ---------- */
@media (max-width: 710px) {
    .downloads-scroll {
        padding: 0 .5rem 24px .5rem;
    }
    
    .downloads-storage {
        padding: 12px;
        gap: 12px;
    }
    
    .storage-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .storage-size {
        font-size: 1rem;
    }
    
    .storage-clear-btn {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
    
    .storage-clear-label {
        display: none;
    }
    
    .download-item {
        padding: 10px 2px;
        gap: 10px;
    }
    
    .download-item-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .download-item-icon .material-icons-round {
        font-size: 1.75rem;    }
    
    .download-item-title {
        font-size: 1rem;
    }
}
.downloads-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #1a1a1a;
    color: #ffffff;
    border-radius: 24px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10005;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid #333333;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    max-width: calc(100vw - 40px);
}

.downloads-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.downloads-toast .material-icons-round {
    font-size: 18px;
    color: #4caf50;
}