/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei",
                 sans-serif;
    background: #f0f4f8;
    color: #2d3748;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #4299e1;
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: #2b6cb0; }

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, #2b6cb0, #4299e1);
    color: #fff;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff !important;
    letter-spacing: 1px;
}

header nav {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.95rem;
}

header nav a {
    color: rgba(255,255,255,0.9);
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}
header nav a:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.nav-right {
    margin-left: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 20px;
    border-left: 1px solid rgba(255,255,255,0.25);
}

.nav-right span {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ===== Main ===== */
main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

/* ===== Flash Messages ===== */
.flash-container { margin-bottom: 20px; }

.flash {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}
.flash-success { background: #c6f6d5; color: #22543d; border-left: 4px solid #48bb78; }
.flash-danger  { background: #fed7d7; color: #742a2a; border-left: 4px solid #f56565; }
.flash-warning { background: #fefcbf; color: #744210; border-left: 4px solid #ecc94b; }
.flash-info    { background: #bee3f8; color: #2a4365; border-left: 4px solid #4299e1; }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 48px 16px;
    background: #fff;
    border-radius: 16px;
    margin-bottom: 32px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.hero h1 { font-size: 2.4rem; margin-bottom: 8px; }
.hero p { font-size: 1.2rem; color: #718096; }

/* ===== Subject Cards ===== */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.subject-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    color: #2d3748 !important;
}
.subject-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.subject-icon {
    font-size: 4rem;
    margin-bottom: 12px;
}

.subject-card h2 { font-size: 1.6rem; margin-bottom: 12px; }

.stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 0.9rem;
    color: #718096;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 16px;
    padding: 8px 0;
}
.breadcrumb a { color: #4299e1; }
.breadcrumb span { color: #2d3748; font-weight: 500; }

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.page-header h1 { font-size: 1.6rem; }
.subtitle { color: #718096; font-size: 0.95rem; }

.admin-actions { display: flex; gap: 8px; }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none !important;
}
.btn-primary   { background: #4299e1; color: #fff; }
.btn-primary:hover { background: #2b6cb0; }
.btn-success   { background: #48bb78; color: #fff; }
.btn-success:hover { background: #38a169; }
.btn-danger    { background: #f56565; color: #fff; }
.btn-danger:hover  { background: #e53e3e; }
.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-secondary:hover { background: #cbd5e0; }

.btn-big { padding: 12px 32px; font-size: 1.1rem; }
.btn-full { width: 100%; padding: 12px; font-size: 1.05rem; }

.btn-small {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-download { background: #ebf8ff; color: #2b6cb0; }
.btn-download:hover { background: #bee3f8; }

/* ===== New Folder Form ===== */
.new-folder-form {
    background: #fff;
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.new-folder-form form {
    display: flex;
    gap: 10px;
    align-items: center;
}
.new-folder-form input[type="text"] {
    flex: 1;
    padding: 8px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.new-folder-form input[type="text"]:focus {
    border-color: #4299e1;
}

/* ===== Folder List ===== */
.folder-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.folder-item {
    background: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    transition: transform 0.15s;
}
.folder-item:hover { transform: translateY(-2px); }

.folder-link {
    font-size: 1.05rem;
    font-weight: 500;
    color: #2d3748 !important;
    flex: 1;
}

/* ===== File Table ===== */
.file-table {
    width: 100%;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border-collapse: collapse;
}
.file-table th, .file-table td {
    padding: 12px 16px;
    text-align: left;
}
.file-table thead {
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
}
.file-table th {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.file-table tbody tr { border-bottom: 1px solid #f0f4f8; }
.file-table tbody tr:last-child { border-bottom: none; }
.file-table tbody tr:hover { background: #f7fafc; }

.filename { font-weight: 500; }
.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.empty-hint {
    text-align: center;
    padding: 40px;
    color: #a0aec0;
    font-size: 1.1rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ===== Section Titles ===== */
section h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: #4a5568;
}

/* ===== Forms ===== */
.form-card {
    background: #fff;
    padding: 28px 32px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #4a5568;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
    border-color: #4299e1;
}

.help-text {
    font-size: 0.85rem;
    color: #a0aec0;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 24px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== Auth ===== */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}
.auth-card {
    background: #fff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 420px;
}
.auth-card h1 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.5rem;
}
.auth-hint {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
}

/* ===== Admin ===== */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}
.admin-card {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.admin-card h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f4f8;
}
.full-width { grid-column: 1 / -1; }

.tag {
    display: inline-block;
    padding: 2px 10px;
    background: #ebf8ff;
    color: #2b6cb0;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 20px;
    color: #a0aec0;
    font-size: 0.85rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    margin-top: auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner { flex-direction: column; height: auto; padding: 12px 0; gap: 8px; }
    header nav { flex-wrap: wrap; justify-content: center; font-size: 0.85rem; }
    .nav-right { margin-left: 0; padding-left: 0; border-left: none; }
    .subjects-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .file-table { font-size: 0.9rem; }
    .file-table th, .file-table td { padding: 8px 10px; }
    .admin-grid { grid-template-columns: 1fr; }
    .new-folder-form form { flex-direction: column; }
}

/* ===== Rename Button ===== */
.btn-rename {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s;
    vertical-align: middle;
}
.btn-rename:hover {
    opacity: 1;
    background: #ebf8ff;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 420px;
}
.modal-content h3 {
    margin-bottom: 20px;
    font-size: 1.2rem;
}
.modal-content .form-actions {
    margin-top: 16px;
}

/* ===== Download Page ===== */
.download-page {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
}
.download-card {
    background: #fff;
    border-radius: 20px;
    padding: 48px 40px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    text-align: center;
    max-width: 520px;
    width: 100%;
}
.file-icon-big {
    font-size: 5rem;
    margin-bottom: 16px;
    line-height: 1;
}
.file-title {
    font-size: 1.5rem;
    word-break: break-all;
    margin-bottom: 28px;
    color: #2d3748;
}
.file-details {
    text-align: left;
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 32px;
}
.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}
.detail-item:last-child {
    border-bottom: none;
}
.detail-label {
    color: #718096;
    font-weight: 500;
}
.detail-value {
    color: #2d3748;
    font-weight: 600;
}
.btn-download-big {
    display: inline-block;
    background: linear-gradient(135deg, #4299e1, #2b6cb0);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 16px 48px;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none !important;
    box-shadow: 0 4px 16px rgba(66,153,225,0.3);
}
.btn-download-big:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(66,153,225,0.4);
    color: #fff;
}
.back-link {
    display: block;
    margin-top: 20px;
    color: #718096;
    font-size: 0.9rem;
}
.back-link:hover {
    color: #4299e1;
}
