/* FullTruck CMS - Admin styles */
:root {
    --brand: #E10712;
    --brand-dark: #B30009;
    --ink: #0a0a0a;
    --ink-2: #141414;
    --ink-3: #1c1c1c;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --text: #f5f5f5;
    --text-muted: #9a9a9a;
    --font-display: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; background: var(--ink); color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ----- Login page ----- */
body.is-login { display: grid; place-items: center; min-height: 100vh; background: var(--ink); position: relative; overflow: hidden; }
body.is-login::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(ellipse 600px 400px at 70% 30%, rgba(225, 7, 18, 0.2), transparent 70%),
                radial-gradient(ellipse 500px 300px at 30% 70%, rgba(225, 7, 18, 0.08), transparent 70%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(14px);
    border: 1px solid var(--line-2);
    border-radius: 16px;
    padding: 48px 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    position: relative; z-index: 1;
}
.login-card .logo { text-align: center; margin-bottom: 32px; }
.login-card .logo img { height: 56px; margin: 0 auto 12px; }
.login-card .logo p { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.18em; }
.login-card h1 { font-family: var(--font-display); font-size: 2rem; margin-bottom: 8px; text-transform: uppercase; }
.login-card .lead { color: var(--text-muted); margin-bottom: 32px; font-size: 0.95rem; }

/* ----- Sidebar ----- */
.admin-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 260px;
    background: var(--ink-2);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: 24px 16px;
    z-index: 10;
}
.admin-brand { padding: 8px 8px 24px; border-bottom: 1px solid var(--line); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.admin-brand img { height: 36px; }
.cms-tag {
    background: var(--brand); color: #fff;
    font-family: var(--font-display);
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.1em;
}

/*
   min-height: 0 es imprescindible: sin él, un hijo flex no puede encogerse por debajo
   del alto de su contenido, así que el menú se desbordaba y quedaba cortado sin scroll.
*/
.admin-nav {
    display: flex; flex-direction: column; gap: 4px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-2) transparent;
    padding-right: 4px;
    margin-right: -4px;
}
.admin-nav::-webkit-scrollbar { width: 6px; }
.admin-nav::-webkit-scrollbar-track { background: transparent; }
.admin-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.admin-nav::-webkit-scrollbar-thumb:hover { background: var(--brand); }
/* Marca y bloque de usuario siempre visibles: no deben encogerse ni desplazarse. */
.admin-brand, .admin-user { flex-shrink: 0; }
.admin-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 500; font-size: 0.92rem;
    color: var(--text-muted);
    transition: all 0.2s;
}
.admin-nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.admin-nav a.active { background: var(--brand); color: #fff; }
.admin-nav svg { width: 18px; height: 18px; }

.admin-user {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 12px;
    border-top: 1px solid var(--line);
    margin-top: 16px;
}
.avatar {
    width: 40px; height: 40px;
    background: var(--brand); color: #fff;
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700;
    flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 0.9rem; line-height: 1; margin-bottom: 4px; }
.logout {
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 0.78rem; text-decoration: underline; padding: 0;
}
.logout:hover { color: var(--brand); }

/* ----- Main ----- */
.admin-main { margin-left: 260px; min-height: 100vh; }
.admin-topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 24px 32px;
    background: var(--ink-2);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 5;
}
.admin-topbar h1 { font-family: var(--font-display); font-size: 1.6rem; text-transform: uppercase; letter-spacing: 0.02em; margin: 0; }
.btn-mini {
    padding: 8px 16px;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.2s;
}
.btn-mini:hover { border-color: var(--brand); color: var(--brand); }

.admin-content { padding: 32px; }

@media (max-width: 900px) {
    .admin-sidebar { width: 80px; padding: 16px 8px; }
    .admin-sidebar .admin-brand img { height: 24px; }
    .cms-tag, .admin-nav a span:not(.cms-tag), .user-name, .logout { display: none; }
    .admin-nav a { justify-content: center; padding: 12px; }
    .admin-user { justify-content: center; }
    .admin-main { margin-left: 80px; }
    .admin-content { padding: 16px; }
}

/* ----- Dashboard cards ----- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-box {
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
    transition: border-color 0.2s;
}
.stat-box:hover { border-color: var(--line-2); }
.stat-box .lbl { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; }
.stat-box .num { font-family: var(--font-display); font-size: 2.6rem; color: var(--brand); margin-top: 8px; line-height: 1; }
.stat-box.alt .num { color: var(--text); }

.panel {
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}
.panel h2 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 16px; text-transform: uppercase; }

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.data {
    width: 100%; border-collapse: collapse;
    background: var(--ink-2);
}
table.data th, table.data td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { background: var(--ink-3); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
table.data tr:hover td { background: rgba(225, 7, 18, 0.04); }
table.data tr:last-child td { border: none; }
.tbl-actions { display: flex; gap: 8px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.pill-on { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.pill-off { background: rgba(239, 68, 68, 0.16); color: #f87171; }
.pill-new { background: var(--brand); color: #fff; }

/* ----- Forms ----- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row.full { grid-template-columns: 1fr; }
.field-grp { display: flex; flex-direction: column; gap: 6px; }
.field-grp label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.field-grp input[type="text"],
.field-grp input[type="email"],
.field-grp input[type="password"],
.field-grp input[type="number"],
.field-grp input[type="url"],
.field-grp textarea,
.field-grp select {
    width: 100%;
    background: var(--ink-3);
    border: 1px solid var(--line-2);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    transition: border-color 0.2s;
}
.field-grp input:focus, .field-grp textarea:focus, .field-grp select:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(225, 7, 18, 0.18);
}
.field-grp .hint { color: var(--text-muted); font-size: 0.75rem; }
.field-grp .err { color: var(--brand); font-size: 0.78rem; }

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ----- Buttons ----- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600; font-size: 0.88rem;
    cursor: pointer; border: 1px solid transparent;
    transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: transparent; color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.12); border-color: #f87171; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.alert { padding: 14px 18px; border-radius: 8px; margin-bottom: 16px; font-size: 0.92rem; }
.alert-success { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.3); color: #4ade80; }
.alert-error { background: rgba(225, 7, 18, 0.12); border: 1px solid rgba(225, 7, 18, 0.4); color: #ff6b75; }

.hd-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }

/* ----- Admin Portfolio grid ----- */
.portfolio-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.portfolio-admin-card {
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.portfolio-admin-card:hover { border-color: var(--line-2); }
.portfolio-admin-card .thumb {
    aspect-ratio: 4 / 3;
    background: var(--ink-3);
    position: relative;
    overflow: hidden;
}
.portfolio-admin-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.portfolio-admin-card .overlay-tag {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0, 0, 0, 0.85); color: #fff;
    padding: 4px 10px; border-radius: 4px;
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
}
.overlay-feat { background: var(--brand); top: auto; bottom: 8px; left: auto; right: 8px; }
.portfolio-admin-card .info { padding: 16px; }
.portfolio-admin-card h4 { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; text-transform: none; letter-spacing: 0; }
.portfolio-admin-card p { color: var(--text-muted); font-size: 0.78rem; margin-bottom: 12px; }
.portfolio-admin-card .actions { display: flex; gap: 6px; }

/* =======================================================================
   THEME TOGGLE (admin + portal cliente) — comparte llave 'ft-theme'
   ======================================================================= */
.theme-toggle {
    width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--line-2); border-radius: 50%;
    color: var(--text); cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.theme-toggle:hover, .theme-toggle:focus-visible { border-color: var(--brand); color: var(--brand); outline: none; }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { width: 18px; height: 18px; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
:root .theme-toggle .icon-moon, [data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root .theme-toggle .icon-sun,  [data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* =======================================================================
   MODO CLARO (DEFAULT) — back-office blanco corporativo
   El dark de arriba queda como tema oscuro; esto lo voltea bajo [data-theme=light].
   ======================================================================= */
[data-theme="light"] {
    --ink:    #ffffff;   /* área de contenido */
    --ink-2:  #f7f7f5;   /* sidebar, topbar, cards, tablas */
    --ink-3:  #efeee9;   /* headers de tabla, inputs */
    --line:   rgba(10, 10, 10, 0.09);
    --line-2: rgba(10, 10, 10, 0.16);
    --text:   #0a0a0a;
    --text-muted: #5a5a5a;
}
[data-theme="light"] body { background: var(--ink); color: var(--text); }

/* Login */
[data-theme="light"] body.is-login { background: #f1f0ec; }
[data-theme="light"] body.is-login::before {
    background: radial-gradient(ellipse 600px 400px at 70% 30%, rgba(225, 7, 18, 0.06), transparent 70%),
                radial-gradient(ellipse 500px 300px at 30% 70%, rgba(225, 7, 18, 0.03), transparent 70%);
}
[data-theme="light"] .login-card {
    background: #ffffff; border-color: var(--line);
    box-shadow: 0 24px 60px rgba(20, 20, 25, 0.10);
}

/* Sidebar / nav */
[data-theme="light"] .admin-sidebar { background: var(--ink-2); border-right: 1px solid var(--line); }
[data-theme="light"] .admin-nav a:hover { background: rgba(10, 10, 10, 0.05); color: var(--text); }
[data-theme="light"] .admin-nav a.active { background: var(--brand); color: #fff; }

/* Topbar / cards / tablas: heredan de las variables ya volteadas. Sólo ajustes finos: */
[data-theme="light"] .stat-box,
[data-theme="light"] .panel,
[data-theme="light"] table.data,
[data-theme="light"] .portfolio-admin-card { box-shadow: 0 6px 18px rgba(20, 20, 25, 0.05); }
[data-theme="light"] table.data tr:hover td { background: rgba(225, 7, 18, 0.05); }
[data-theme="light"] .field-grp input:focus,
[data-theme="light"] .field-grp textarea:focus,
[data-theme="light"] .field-grp select:focus { box-shadow: 0 0 0 3px rgba(225, 7, 18, 0.10); }

/* Logo por tema (sidebar + login). Reglas GLOBALES — el login no está en .admin-brand. */
.brand-logo-dark  { display: none; }
.brand-logo-light { display: block; }
[data-theme="dark"] .brand-logo-dark  { display: block; }
[data-theme="dark"] .brand-logo-light { display: none; }
.admin-brand .brand-logo { height: 36px; width: auto; }
.login-card .logo .brand-logo { height: 56px; width: auto; margin: 0 auto; }
