/* ============================================================
   Bataller Contenidos - Cloud
   Sistema de diseno unico oscuro/bordo. Ver cloud/DESIGN.md.
   ============================================================ */

/* 1. Tokens ---------------------------------------------------- */
:root {
    --bg:        #1a1a1a;
    --surface:   #242526;
    --border:    #383838;
    --row-hover: #2d2e2f;
    --primary:   #9d2050;
    --primary-h: #7a1840;
    --danger:    #e62a2a;
    --success:   #22c55e;
    --warn:      #f59e0b;
    --info:      #3b82f6;
    --purple:    #8b5cf6;
    --text:      #f0f0f0;
    --muted:     #9ca0a4;
    --radius:    10px;
    --shadow:    0 1px 4px rgba(0,0,0,.45);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.65);
}

/* 2. Reset & base --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* 3. Layout principal ---------------------------------------- */
.layout  { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--primary);
           border-right: 1px solid rgba(0,0,0,.25);
           display: flex; flex-direction: column; flex-shrink: 0; }
.main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar  { background: var(--primary);
           border-bottom: 1px solid rgba(0,0,0,.25);
           padding: 0 24px; height: 60px;
           display: flex; align-items: center; justify-content: space-between;
           box-shadow: var(--shadow); }
.content { flex: 1; padding: 24px; overflow-y: auto; }

/* 4. Sidebar -------------------------------------------------- */
.sidebar-logo       { height: 60px; padding: 0 20px;
                      border-bottom: 1px solid rgba(0,0,0,.2);
                      display: flex; align-items: center; justify-content: center;
                      flex-shrink: 0; }
.sidebar-logo-mark  { display: block; width: auto; height: 28px;
                      max-width: 100%; object-fit: contain; }
.sidebar-logo-text  { color: #fff; font-weight: 700; font-size: .95rem;
                      letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav        { padding: 8px 0 12px; flex: 1; overflow-y: auto; }
.sidebar-footer     { padding: 10px 20px; font-size: .72rem;
                      color: rgba(255,255,255,.7);
                      border-top: 1px solid rgba(0,0,0,.2);
                      text-align: center; letter-spacing: .03em;
                      font-family: monospace; }

.nav-item { display: flex; align-items: center; gap: 10px;
            padding: 10px 20px; font-size: .9rem;
            color: rgba(255,255,255,.85); cursor: pointer;
            border-left: 3px solid transparent;
            transition: background .15s, color .15s;
            text-decoration: none; width: 100%; background: none; border-top: none; border-right: none; border-bottom: none;
            text-align: left; font-family: inherit; }
.nav-item:hover  { background: rgba(0,0,0,.18); color: #fff; }
.nav-item.active { background: rgba(0,0,0,.28); color: #fff;
                   border-left-color: #fff; font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* 5. Topbar --------------------------------------------------- */
.topbar-title    { font-size: 1rem; font-weight: 600; flex: 1; color: #fff; }

.topbar-user     { display: flex; align-items: center; gap: 10px;
                   flex-shrink: 0; position: relative; }
.topbar-username { background: none; border: none; cursor: pointer;
                   font-size: .85rem; color: rgba(255,255,255,.9);
                   display: flex; align-items: center; gap: 6px;
                   padding: 6px 10px; border-radius: 8px;
                   transition: background .15s, color .15s;
                   font-family: inherit; }
.topbar-username:hover { background: rgba(0,0,0,.18); color: #fff; }
.topbar .hamburger     { display: none; background: none; border: none;
                         cursor: pointer; font-size: 1.4rem; color: #fff;
                         padding: 4px 8px; margin-right: 8px; line-height: 1; }

.user-dropdown   { display: none; position: absolute; right: 0;
                   top: calc(100% + 6px); background: var(--surface);
                   border: 1px solid var(--border); border-radius: 10px;
                   box-shadow: var(--shadow-lg);
                   min-width: 180px; overflow: hidden; z-index: 200; }
.user-dropdown.open { display: block; }
.user-dropdown-item { display: flex; align-items: center; gap: 10px;
                      padding: 10px 14px; width: 100%; background: none;
                      border: none; cursor: pointer; color: var(--text);
                      font-size: .85rem; font-family: inherit; text-align: left;
                      transition: background .15s, color .15s; }
.user-dropdown-item:hover { background: var(--bg); color: var(--primary); }

/* 6. Botones -------------------------------------------------- */
.btn { padding: 8px 16px; border-radius: var(--radius); border: none;
       font-size: .88rem; font-weight: 600; cursor: pointer;
       display: inline-flex; align-items: center; justify-content: center;
       gap: 6px; transition: background .15s, transform .1s;
       font-family: inherit; }
.btn:active        { transform: scale(.97); }
.btn-primary       { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger        { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #c91515; }
.btn-secondary     { background: var(--surface); color: var(--text);
                     border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost         { background: transparent; color: var(--muted);
                     border: 1px solid var(--border); }
.btn-ghost:hover   { background: var(--bg); color: var(--text); }
.btn-sm            { padding: 5px 12px; font-size: .8rem; }
.btn-icon-sm       { background: none; border: none; cursor: pointer;
                     padding: 4px 8px; border-radius: 6px; font-size: .85rem;
                     color: var(--muted); font-family: inherit; }
.btn-icon-sm:hover { background: var(--bg); color: var(--text); }

/* 7. Inputs --------------------------------------------------- */
input[type=text], input[type=number], input[type=url], input[type=tel],
input[type=email], input[type=date], input[type=time], input[type=datetime-local],
input[type=password], input[type=search], select, textarea {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 12px; font-size: .88rem; background: var(--surface);
    color: var(--text); outline: none; transition: border .15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(157,32,80,.25);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
    color: var(--muted); background: var(--bg);
    cursor: not-allowed; opacity: .75;
}
textarea { resize: vertical; min-height: 60px; }

.field-error   { margin-top: 4px; font-size: .78rem; color: var(--danger); }
.input-invalid { border-color: var(--danger) !important;
                 box-shadow: 0 0 0 2px rgba(239,68,68,.18); }

/* 8. Formularios --------------------------------------------- */
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3  { grid-template-columns: repeat(3, 1fr); }
.form-row-4  { grid-template-columns: repeat(4, 1fr); }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }

/* 10. Tablas -------------------------------------------------- */
.table-card { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); box-shadow: var(--shadow);
              overflow-x: auto; overflow-y: hidden; }

table       { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead tr    { background: var(--bg); }
th          { padding: 10px 14px; text-align: left;
              font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
              color: var(--muted); font-weight: 600;
              border-bottom: 1px solid var(--border); white-space: nowrap; }
td          { padding: 10px 14px; border-bottom: 1px solid var(--border);
              vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }

.td-id      { color: var(--muted); font-size: .8rem; }
.td-nombre  { font-weight: 600; }
.table-empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* 11. Badges -------------------------------------------------- */
.badge         { display: inline-block; padding: 2px 10px;
                 border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-info    { background: rgba(59,130,246,.18); color: #93c5fd; }
.badge-success { background: rgba(34,197,94,.18);  color: #86efac; }
.badge-danger  { background: rgba(230,42,42,.2);   color: #f5a8a8; }
.badge-warn    { background: rgba(245,158,11,.18); color: #fcd34d; }

/* 12. Stat cards --------------------------------------------- */
.stats-bar  { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card  { background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); padding: 14px 20px;
              display: flex; flex-direction: column; gap: 2px;
              flex: 1; min-width: 140px; }
.stat-label { font-size: .72rem; color: var(--muted);
              text-transform: uppercase; letter-spacing: .04em;
              font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-value.green   { color: var(--success); }
.stat-value.primary { color: var(--primary); }
.stat-value.red     { color: var(--danger); }
.stat-value.muted   { color: var(--muted); font-size: 1.2rem; }
.stat-sub   { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* 13. Dashboard grid ----------------------------------------- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr;
             gap: 20px; margin-top: 4px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-table-header { padding: 14px 20px 10px;
                     font-weight: 600; font-size: .95rem;
                     border-bottom: 1px solid var(--border);
                     display: flex; align-items: center;
                     justify-content: space-between; }
.dash-ver-mas      { font-size: .78rem; font-weight: 500; color: var(--primary); }

/* 16. Toasts ------------------------------------------------- */
.toast { position: fixed; bottom: 24px; left: 50%;
         transform: translateX(-50%) translateY(16px);
         background: #0d0d0d; color: var(--text);
         border: 1px solid var(--border);
         padding: 10px 20px; border-radius: 99px;
         font-size: .88rem; opacity: 0; pointer-events: none;
         transition: opacity .2s, transform .2s;
         z-index: 200; white-space: nowrap;
         box-shadow: var(--shadow-lg); }
.toast.show  { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 18. Spinner ------------------------------------------------ */
.spin { display: inline-block; width: 28px; height: 28px;
        border: 3px solid var(--border); border-top-color: var(--primary);
        border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 19. Responsive --------------------------------------------- */
.sidebar-overlay  { display: none; position: fixed; inset: 0;
                    background: rgba(0,0,0,.45); z-index: 199; }
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
    .topbar .hamburger { display: inline-flex; align-items: center; }
    .sidebar   { position: fixed; top: 0; left: 0; height: 100vh;
                 z-index: 200; transform: translateX(-100%);
                 transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}

/* 23. Module header ----------------------------------------- */
.module-header   { margin-bottom: 18px; }
.module-title    { font-size: 1.35rem; font-weight: 700;
                   color: var(--text); margin: 0 0 4px; line-height: 1.2; }
.module-subtitle { font-size: .88rem; color: var(--muted);
                   margin: 0; line-height: 1.4; }

/* Banner de nueva version disponible -------------------------- */
.version-banner { display: none; position: fixed; bottom: 24px; right: 24px;
                  background: var(--surface); border: 1px solid var(--primary);
                  border-radius: var(--radius); padding: 12px 16px;
                  box-shadow: var(--shadow-lg); z-index: 150;
                  align-items: center; gap: 12px; font-size: .85rem;
                  max-width: 320px; }
.version-banner.show { display: flex; }
.version-banner-text { color: var(--text); flex: 1; }
.version-banner-btn  { padding: 4px 10px; font-size: .78rem; }

/* 27-bis. Login --------------------------------------------- */
body.login-page { background: var(--bg); min-height: 100vh; }

.login-shell    { min-height: 100vh; display: flex;
                  align-items: center; justify-content: center; padding: 24px; }
.login-card     { width: 100%; max-width: 360px;
                  background: var(--primary);
                  border: 1px solid rgba(0,0,0,.25);
                  border-radius: 14px; box-shadow: var(--shadow-lg);
                  padding: 28px 28px 24px;
                  display: flex; flex-direction: column; gap: 16px;
                  color: #fff; }
.login-brand    { display: flex; align-items: center; justify-content: center; padding: 4px 0 0; }
.login-logo     { display: block; height: 44px; max-width: 80%; object-fit: contain; }
.login-title    { font-size: 1.2rem; font-weight: 700;
                  text-align: center; color: #fff; }
.login-subtitle { font-size: .85rem; color: rgba(255,255,255,.78);
                  text-align: center; margin-top: -8px; }

.login-form     { display: flex; flex-direction: column; gap: 12px; }
.login-form .form-group label { color: rgba(255,255,255,.88); }
.login-form input[type=text],
.login-form input[type=password] {
    background: rgba(0,0,0,.22);
    border: 1px solid rgba(0,0,0,.35);
    color: #fff;
}
.login-form input::placeholder { color: rgba(255,255,255,.55); }
.login-form input:focus {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,.22);
}

.login-error {
    color: #fff;
    background: rgba(0,0,0,.28);
    border: 1px solid rgba(0,0,0,.35);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: .82rem;
}

.login-page .btn-primary       { background: #fff; color: var(--primary); }
.login-page .btn-primary:hover { background: rgba(255,255,255,.9); color: var(--primary-h); }

.login-submit { justify-content: center; padding: 10px 16px; margin-top: 4px; }
