/* =============================================================
   EduBás Admin — Estilos del panel de administración
   ============================================================= */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --adm-sidebar-w:  240px;
    --adm-topbar-h:   56px;
    --adm-bg:         #f8f8f8;
    --adm-surface:    #ffffff;
    --adm-sidebar-bg: #0f0f0f;
    --adm-sidebar-txt:#c8c8c8;
    --adm-sidebar-active: #ffffff;
    --adm-border:     #e8e8e8;
    --adm-text:       #1a1a1a;
    --adm-muted:      #888;
    --adm-accent:     #1a1a1a;
    --adm-danger:     #dc2626;
    --adm-success:    #16a34a;
    --adm-warning:    #d97706;
    --adm-info:       #2563eb;
    --adm-radius:     8px;
    --adm-shadow:     0 1px 4px rgba(0,0,0,.08);
    --adm-t:          0.2s ease;
    --font:           'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); color: var(--adm-text); background: var(--adm-bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
ul, ol { list-style: none; }

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

/* Sidebar */
.admin-sidebar {
    width: var(--adm-sidebar-w);
    background: var(--adm-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transition: transform var(--adm-t);
    overflow-y: auto;
}

.sidebar__brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__logo {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    font-weight: 700;
    color: #fff;
    opacity: 1;
}
.sidebar__logo:hover { opacity: .85; }
.sidebar__logo-icon {
    font-size: 1.3rem;
    transition: transform .3s;
}
.sidebar__logo:hover .sidebar__logo-icon { transform: rotate(45deg); }

.sidebar__nav {
    flex: 1;
    padding: .75rem 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.sidebar__link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1rem;
    border-radius: 6px;
    margin: 0 .5rem;
    font-size: .85rem;
    font-weight: 500;
    color: var(--adm-sidebar-txt);
    transition: background var(--adm-t), color var(--adm-t);
}
.sidebar__link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    opacity: 1;
}
.sidebar__link--active {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.sidebar__link-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar__footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.sidebar__view-site,
.sidebar__logout {
    font-size: .8rem;
    color: var(--adm-sidebar-txt);
    padding: .4rem .5rem;
    border-radius: 4px;
    transition: color var(--adm-t);
}
.sidebar__view-site:hover { color: #fff; opacity: 1; }
.sidebar__logout {
    color: #f87171;
}
.sidebar__logout:hover { color: #fca5a5; opacity: 1; }

/* Main content */
.admin-main {
    margin-left: var(--adm-sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.admin-topbar {
    height: var(--adm-topbar-h);
    background: var(--adm-surface);
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 40;
}
.admin-topbar__title {
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    color: var(--adm-text);
}
.admin-topbar__user {
    font-size: .825rem;
    color: var(--adm-muted);
}
.sidebar-toggle {
    font-size: 1.2rem;
    color: var(--adm-text);
    display: none;
    padding: .25rem;
}

/* Admin content */
.admin-content {
    padding: 1.75rem;
    flex: 1;
}

/* Flash messages */
.flash {
    margin: 0 1.75rem;
    padding: .75rem 1rem;
    border-radius: var(--adm-radius);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 0;
}
.flash--success {
    background: #dcfce7;
    color: var(--adm-success);
    border: 1px solid #bbf7d0;
}
.flash--error {
    background: #fee2e2;
    color: var(--adm-danger);
    border: 1px solid #fecaca;
}

/* ── Componentes ────────────────────────────────────────────── */

/* Cabecera de sección */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--adm-text);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--adm-radius);
    font-size: .85rem;
    font-weight: 600;
    transition: all var(--adm-t);
    white-space: nowrap;
    border: 1px solid transparent;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--adm-accent); color: #fff; }
.btn-secondary { background: var(--adm-surface); color: var(--adm-text); border-color: var(--adm-border); }
.btn-secondary:hover { background: var(--adm-bg); }
.btn-danger { background: var(--adm-danger); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }

/* Tarjeta / Card */
.card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    overflow: hidden;
}
.card__body { padding: 1.5rem; }
.card__header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--adm-border);
    font-size: .875rem;
    font-weight: 600;
    color: var(--adm-text);
}

/* Tabla */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.table th {
    text-align: left;
    padding: .65rem 1rem;
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--adm-muted);
    background: var(--adm-bg);
    border-bottom: 1px solid var(--adm-border);
    white-space: nowrap;
}
.table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--adm-border);
    color: var(--adm-text);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--adm-bg); }

.table-thumb {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--adm-bg);
}
.table-actions { display: flex; gap: .4rem; }

/* Formularios */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 768px) {
    .form-grid--2 { grid-template-columns: 1fr 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group--full { grid-column: 1 / -1; }

.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--adm-text);
    letter-spacing: .02em;
}
.form-label span { color: var(--adm-danger); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: .55rem .875rem;
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    font-size: .9rem;
    color: var(--adm-text);
    background: var(--adm-surface);
    transition: border-color var(--adm-t), box-shadow var(--adm-t);
    appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.form-textarea { min-height: 120px; resize: vertical; }

.form-hint { font-size: .78rem; color: var(--adm-muted); }

.form-actions {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 1rem;
    margin-top: .5rem;
    border-top: 1px solid var(--adm-border);
}

/* Editor Quill — Estilos idénticos al frontend (.post-content 720px WYSIWYG) */
.ql-container.ql-snow {
    min-height: 400px;
    font-size: 1.0625rem;
    line-height: 1.8;
    border-radius: 0 0 var(--adm-radius) var(--adm-radius);
    border-color: var(--adm-border);
    background: #ffffff;
}
.ql-toolbar.ql-snow {
    border-radius: var(--adm-radius) var(--adm-radius) 0 0;
    border-color: var(--adm-border);
    background: #fafafa;
    position: sticky;
    top: var(--adm-topbar-h);
    z-index: 30;
}
.ql-editor {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.5rem !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #2c2c2c;
    min-height: 400px;
}
.ql-editor img {
    max-width: 100%;
    border-radius: 8px;
}

/* Vista previa de imagen */
.img-preview-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.img-preview {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--adm-border);
}

/* Dashboard stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (min-width: 768px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.stat-card__icon { font-size: 1.5rem; margin-bottom: .25rem; }
.stat-card__value { font-size: 1.75rem; font-weight: 700; color: var(--adm-text); }
.stat-card__label { font-size: .8rem; color: var(--adm-muted); font-weight: 500; }

/* Confirm modal */
.confirm-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.confirm-dialog.open { opacity: 1; pointer-events: all; }
.confirm-dialog__box {
    background: #fff;
    border-radius: var(--adm-radius);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.confirm-dialog__title { font-weight: 700; margin-bottom: .5rem; }
.confirm-dialog__text { font-size: .9rem; color: var(--adm-muted); margin-bottom: 1.5rem; }
.confirm-dialog__actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--adm-bg);
    padding: 1rem;
}
.login-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,.06);
}
.login-card__logo {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-card__logo-icon { font-size: 2rem; display: block; margin-bottom: .5rem; }
.login-card__logo h1 { font-size: 1.1rem; font-weight: 700; }
.login-card__logo p { font-size: .8rem; color: var(--adm-muted); }
.login-error {
    background: #fee2e2;
    color: var(--adm-danger);
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: .6rem .875rem;
    font-size: .85rem;
    margin-bottom: 1rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.2);
    }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .admin-content { padding: 1rem; }
}

/* ── Floating Image Toolbar for Quill Editor ──────────────── */
.selected-quill-img {
    outline: 3px solid #2563eb !important;
    outline-offset: 2px;
}

.quill-img-toolbar {
    position: absolute;
    z-index: 9999;
    background: #1e293b;
    color: #fff;
    padding: .4rem .6rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .8rem;
    user-select: none;
}
.quill-img-toolbar::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}
.quill-img-group {
    display: flex;
    align-items: center;
    gap: .25rem;
}
.quill-img-label {
    color: #94a3b8;
    font-size: .75rem;
    margin-right: .2rem;
}
.quill-img-toolbar button {
    background: #334155;
    color: #f1f5f9;
    border: none;
    padding: .25rem .5rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.quill-img-toolbar button:hover {
    background: #475569;
    color: #fff;
}
.quill-img-toolbar button.danger {
    background: #7f1d1d;
    color: #fca5a5;
}
.quill-img-toolbar button.danger:hover {
    background: #991b1b;
    color: #fff;
}
.quill-img-size-badge {
    background: #0f172a;
    color: #38bdf8;
    padding: .2rem .4rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
    font-family: monospace;
    min-width: 40px;
    text-align: center;
}

