/* ============================================================
   Sistema de Seguimiento de Proyectos – Datasys
   Paleta: azul corporativo + grises limpios
   ============================================================ */

:root {
    --brand:       #1a56db;
    --brand-dark:  #1246b8;
    --brand-light: #e8effc;
    --success:     #15803d;
    --success-bg:  #dcfce7;
    --warn:        #b45309;
    --warn-bg:     #fef3c7;
    --danger:      #b91c1c;
    --danger-bg:   #fee2e2;
    --gray-50:     #f8fafc;
    --gray-100:    #f1f5f9;
    --gray-200:    #e2e8f0;
    --gray-300:    #cbd5e1;
    --gray-500:    #64748b;
    --gray-700:    #334155;
    --gray-900:    #0f172a;
    --radius:      6px;
    --sidebar-w:   220px;
    --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--gray-900);
    background: var(--gray-50);
    min-height: 100vh;
}

/* ── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.full-width { width: 100%; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }

/* ── Login ─────────────────────────────────────────────────── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a3a6b 0%, #1a56db 100%);
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 36px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--brand); margin: 4px 0 2px; }
.login-logo p  { color: var(--gray-500); font-size: 13px; }

/* ── Forms ─────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 13px; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}
.field textarea { resize: vertical; min-height: 80px; }
.error-msg { color: var(--danger); font-size: 13px; padding: 8px; background: var(--danger-bg); border-radius: var(--radius); margin-bottom: 12px; }
.error-msg:empty { display: none; }

/* ── Buttons ───────────────────────────────────────────────── */
button, .btn { cursor: pointer; border: none; border-radius: var(--radius); font-family: var(--font); font-size: 14px; font-weight: 500; padding: 8px 16px; transition: background .15s, opacity .15s; }
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger   { background: var(--danger-bg); color: var(--danger); }
.btn-ghost    { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-icon     { padding: 6px; border-radius: 4px; }

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

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-title { font-weight: 700; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}
.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
}
.nav-icon { width: 18px; text-align: center; }
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: rgba(255,255,255,.6);
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p  { color: var(--gray-500); font-size: 13px; margin-top: 2px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
}

/* ── Proyecto card ─────────────────────────────────────────── */
.proyectos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.proyecto-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px 18px;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.proyecto-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    border-color: var(--gray-300);
}
.proyecto-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.proyecto-codigo { font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-light); padding: 2px 8px; border-radius: 20px; }
.proyecto-estado { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.estado-activo    { background: var(--success-bg); color: var(--success); }
.estado-pausado   { background: var(--warn-bg); color: var(--warn); }
.estado-completado { background: var(--gray-100); color: var(--gray-500); }
.estado-cancelado  { background: var(--danger-bg); color: var(--danger); }

.proyecto-cliente { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.proyecto-pm { font-size: 12px; color: var(--gray-500); margin-bottom: 12px; }

/* ── Barra de progreso ─────────────────────────────────────── */
.progress-bar-wrap { margin-top: 8px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.progress-track { height: 6px; background: var(--gray-200); border-radius: 20px; overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 20px; background: var(--brand); transition: width .4s; }
.progress-fill.done { background: var(--success); }

/* ── Tabla ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--gray-200); font-weight: 600; color: var(--gray-700); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:hover td { background: var(--gray-50); }

/* ── Checklist ─────────────────────────────────────────────── */
.checklist-cell { text-align: center; }
.check-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all .15s;
}
.check-btn.done { background: var(--success); border-color: var(--success); color: #fff; }
.check-btn:hover:not(.done) { border-color: var(--brand); background: var(--brand-light); }

/* ── Badge ─────────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.badge-brand { background: var(--brand-light); color: var(--brand); }

/* ── Divisiones ────────────────────────────────────────────── */
.division-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 0 8px;
    border-bottom: 2px solid var(--brand-light);
    margin-bottom: 12px;
}
.division-header h3 { font-size: 14px; font-weight: 700; color: var(--brand); }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-btn {
    padding: 8px 16px; cursor: pointer; border: none; background: none;
    font-size: 13px; font-weight: 500; color: var(--gray-500);
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-btn:hover:not(.active) { color: var(--gray-700); }

/* ── Loading ───────────────────────────────────────────────── */
.spinner { text-align: center; padding: 60px; color: var(--gray-500); font-size: 13px; }
.spinner::before { content: "⏳ "; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: slideIn .2s ease; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Avance semanal ────────────────────────────────────────── */
.avance-row input[type=number] { width: 70px; padding: 4px 8px; text-align: right; border: 1px solid var(--gray-300); border-radius: 4px; }
.avance-row input[type=text]   { width: 160px; padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px; }

/* ── Modal overlay ─────────────────────────────────────────── */
/* Los modales usan .modal-overlay para mostrarse con flex,
   y .hidden para ocultarse. No mezclar con style.display inline. */
.modal-overlay {
    display: flex !important;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    align-items: center;
    justify-content: center;
    z-index: 999;
}

/* ── Formulario nuevo proyecto ─────────────────────────────── */
.form-section {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-100);
}
.section-header h3 { font-size: 15px; font-weight: 700; color: var(--gray-900); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field--wide { grid-column: 1 / -1; }

.form-field label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.form-field label .required { color: var(--danger); margin-left: 2px; }

.form-field input,
.form-field select,
.form-field textarea {
    padding: 7px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--gray-900);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}
.form-field textarea { resize: vertical; min-height: 72px; }

/* Tarjeta de division */
.division-card {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.division-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    gap: 10px;
}
.division-card-header select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    background: #fff;
}
.division-card-body { padding: 12px 16px; }

/* Filas de racks */
.rack-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.rack-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
}
.rack-salidas-input {
    width: 90px;
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    text-align: right;
}
.rack-input:focus,
.rack-salidas-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-light);
}
.rack-label { font-size: 11px; color: var(--gray-500); white-space: nowrap; }

/* Botones de texto / link */
.btn-link {
    background: none;
    border: none;
    color: var(--brand);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background .15s;
}
.btn-link:hover { background: var(--brand-light); }

.btn-danger-ghost {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    transition: background .15s;
    line-height: 1;
}
.btn-danger-ghost:hover { background: var(--danger-bg); }

/* Acciones del formulario */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}
