/* Admin Panel Styles - Trường THCS Trần Phú */
:root {
    --admin-sidebar: #1e293b;
    --admin-sidebar-hover: #334155;
    --admin-accent: #da251d;
    --admin-accent-light: #fef2f2;
    --admin-bg: #f1f5f9;
    --admin-card: #ffffff;
    --admin-border: #e2e8f0;
    --admin-text: #1e293b;
    --admin-muted: #64748b;
    --admin-success: #059669;
    --admin-warning: #d97706;
    --admin-danger: #dc2626;
}

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

body.admin-body {
    font-family: 'Inter', 'Roboto', sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    min-height: 100vh;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #da251d 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--admin-accent) 0%, #a81c16 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.login-header .school-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-header p {
    font-size: 0.875rem;
    opacity: 0.9;
}

.login-form {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--admin-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--admin-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 3px rgba(218, 37, 29, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--admin-accent);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #a81c16;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--admin-border);
    color: var(--admin-text);
}

.btn-secondary:hover { background: #cbd5e1; }

.btn-success {
    background: var(--admin-success);
    color: white;
}

.btn-success:hover { background: #047857; }

.btn-danger {
    background: var(--admin-danger);
    color: white;
}

.btn-danger:hover { background: #b91c1c; }

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--admin-border);
    color: var(--admin-text);
}

.btn-outline:hover {
    border-color: var(--admin-accent);
    color: var(--admin-accent);
}

.login-footer {
    padding: 0 2rem 2rem;
    text-align: center;
}

.login-footer a {
    color: var(--admin-muted);
    font-size: 0.875rem;
    text-decoration: none;
}

.login-footer a:hover { color: var(--admin-accent); }

.login-hint {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.8125rem;
    color: #0369a1;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Admin Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: var(--admin-sidebar);
    color: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.sidebar-brand span {
    font-size: 0.75rem;
    color: #94a3b8;
    display: block;
    margin-top: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: var(--admin-sidebar-hover);
    color: white;
}

.sidebar-nav li a.active {
    border-left: 3px solid var(--admin-accent);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--admin-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.user-details .name {
    font-size: 0.875rem;
    font-weight: 600;
}

.user-details .role {
    font-size: 0.75rem;
    color: #94a3b8;
}

.admin-main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.admin-topbar {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.admin-topbar h1 {
    font-size: 1.375rem;
    font-weight: 700;
}

.admin-content {
    padding: 2rem;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--admin-border);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--admin-accent);
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--admin-muted);
    margin-top: 0.25rem;
}

/* Tables */
.admin-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
}

.card-body {
    padding: 1.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--admin-border);
    font-size: 0.875rem;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--admin-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-published { background: #d1fae5; color: #065f46; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-admin { background: #dbeafe; color: #1e40af; }
.badge-teacher { background: #ede9fe; color: #5b21b6; }

.action-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Editor */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

.editor-main {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--admin-border);
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--admin-text);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover,
.toolbar-btn.active {
    background: white;
    border-color: var(--admin-border);
    color: var(--admin-accent);
}

.toolbar-divider {
    width: 1px;
    background: var(--admin-border);
    margin: 0 0.25rem;
}

.editor-title-input {
    width: 100%;
    padding: 1.25rem 1.5rem;
    border: none;
    border-bottom: 1px solid var(--admin-border);
    font-size: 1.5rem;
    font-weight: 700;
    font-family: inherit;
    outline: none;
}

.editor-title-input::placeholder {
    color: #cbd5e1;
}

.editor-summary-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: none;
    border-bottom: 1px solid var(--admin-border);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    color: var(--admin-muted);
}

.editor-content {
    min-height: 400px;
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.8;
    outline: none;
}

.editor-content:empty::before {
    content: 'Bắt đầu viết nội dung bài viết tại đây...';
    color: #cbd5e1;
}

.editor-content h2 { font-size: 1.375rem; margin: 1.5rem 0 0.75rem; }
.editor-content h3 { font-size: 1.125rem; margin: 1.25rem 0 0.5rem; }
.editor-content p { margin-bottom: 1rem; }
.editor-content ul, .editor-content ol { margin: 1rem 0 1rem 1.5rem; }
.editor-content img { max-width: 100%; border-radius: 8px; margin: 1rem 0; }

.editor-sidebar .sidebar-panel {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    margin-bottom: 1rem;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--admin-border);
    background: #f8fafc;
}

.panel-body {
    padding: 1.25rem;
}

.panel-body .form-group {
    margin-bottom: 1rem;
}

.panel-body .form-group:last-child {
    margin-bottom: 0;
}

.image-preview {
    width: 100%;
    height: 160px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 2px dashed var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.image-preview:hover { border-color: var(--admin-accent); }

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview .placeholder {
    text-align: center;
    color: var(--admin-muted);
    font-size: 0.875rem;
}

.publish-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.checkbox-label input { width: auto; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 1.125rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--admin-muted);
    line-height: 1;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--admin-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--admin-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 1024px) {
    .editor-layout { grid-template-columns: 1fr; }
}

/* ===== Editor đơn giản cho giáo viên ===== */
.teacher-guide {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #fef2f2 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.guide-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #334155;
}

.step-num {
    width: 24px;
    height: 24px;
    background: var(--admin-accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.image-action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: #f0fdf4;
    border-bottom: 2px solid #bbf7d0;
}

.btn-image-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: #059669;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}

.btn-image-primary:hover {
    background: #047857;
    transform: translateY(-1px);
}

.btn-image-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: white;
    color: #1d4ed8;
    border: 2px solid #93c5fd;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-image-secondary:hover {
    background: #eff6ff;
    border-color: #3b82f6;
}

.image-hint {
    font-size: 0.8125rem;
    color: #166534;
    flex: 1;
    min-width: 200px;
}

.cover-drop-zone {
    width: 100%;
    min-height: 140px;
    background: #f8fafc;
    border-radius: 10px;
    border: 2px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 0.75rem;
}

.cover-drop-zone:hover,
.cover-drop-zone.drag-over {
    border-color: var(--admin-accent);
    background: #fef2f2;
}

.cover-drop-zone img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.upload-prompt {
    text-align: center;
    padding: 1rem;
    color: var(--admin-muted);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

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

.cover-size-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.size-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #475569;
}

.size-badge.success {
    background: #d1fae5;
    color: #065f46;
}

.size-badge.drive {
    background: #dbeafe;
    color: #1e40af;
}

.panel-desc {
    font-size: 0.8125rem;
    color: var(--admin-muted);
    margin-bottom: 0.75rem;
}

.panel-highlight {
    border-color: #86efac;
    box-shadow: 0 0 0 1px #bbf7d0;
}

.panel-info {
    background: #fffbeb;
    border-color: #fde68a;
}

.panel-info .panel-header {
    background: #fef3c7;
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

.editor-content[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: #cbd5e1;
    pointer-events: none;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-box {
    background: white;
    border-radius: 16px;
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--admin-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--admin-text);
}

@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-main { margin-left: 0; }

    .mobile-menu-btn { display: block; }

    .admin-content { padding: 1rem; }

    .data-table { font-size: 0.8125rem; }

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