/* ============================================================================
   IMPORTKOMTROL — Sistema de diseño (tokens)
   Rediseño visual UI/UX Premium
   ============================================================================ */
:root {

    /* Marca - Indigo Corporativo Premium */
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-soft: #eef2ff;
    --brand-ring: rgba(79, 70, 229, .25);

    /* Neutros */
    --ink: #111827;
    --ink-soft: #4b5563;
    --ink-faint: #9ca3af;
    --surface: #ffffff;
    --canvas: #f3f4f6;
    --border: #e5e7eb;
    --border-soft: #f3f4f6;

    /* Estado */
    --success: #059669;
    --success-soft: #d1fae5;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --info: #2563eb;
    --info-soft: #dbeafe;

    /* Forma y Profundidad (Estilo Stripe/Linear) */
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    /* Alias de compatibilidad */
    --odoo: var(--brand);
    --odoo-dark: var(--brand-hover);
    --line: var(--border);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--canvas);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 0; }
a { color: var(--brand); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--brand-hover); }

/* ---- Autenticación ---- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at center, #ffffff 0%, var(--canvas) 100%);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 { font-size: 1.5rem; margin: 0 0 6px; color: var(--ink); }
.auth-card p.sub { margin: 0 0 28px; color: var(--ink-soft); font-size: 0.9rem; }

/* ---- Formularios Súper Profesionales ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); letter-spacing: 0.01em; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02) inset;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-ring);
}
.field input:disabled, .field select:disabled, .field textarea:disabled {
    background: #f9fafb;
    color: var(--ink-faint);
    cursor: not-allowed;
}

/* ---- Botones Premium ---- */
.btn-primary {
    width: 100%;
    padding: 11px 18px;
    background: var(--brand);
    color: #ffffff;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.15);
}
.btn-primary:hover { background: var(--brand-hover); box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; transform: none; }

.btn-secondary {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.btn-secondary:hover { background: #f9fafb; color: var(--ink); border-color: #d1d5db; box-shadow: var(--shadow-md); }

.btn-danger {
    padding: 10px 16px;
    background: #ffffff;
    color: var(--danger);
    border: 1px solid #fca5a5;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-link { color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 0.85rem; transition: color 0.15s; }
.btn-link:hover { color: var(--brand); }

/* ---- Alertas Modernas ---- */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }

/* ---- Tablas Limpias ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; font-weight: 600; color: var(--ink-soft); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

.badge { padding: 4px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; }
.badge-admin { background: var(--brand-soft); color: var(--brand-hover); }
.badge-user { background: var(--border-soft); color: var(--ink-soft); }
.badge-active { background: var(--success-soft); color: #166534; }
.badge-inactive { background: var(--danger-soft); color: #991b1b; }

/* ---- Vistas Generales / Kanban / Dashboard ---- */
.topbar { display: none; } /* Oculto ya que usamos SaaS layout */
.container { max-width: 960px; margin: 28px auto; padding: 0 20px; }

.dash-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; flex-wrap: wrap; gap: 12px; }
.dash-header h2 { margin: 0 0 3px; color: var(--ink); font-size: 1.6rem; }
.dash-header .sub { color: var(--ink-soft); font-size: 0.95rem; margin: 0; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 16px; margin: 24px 0 16px; }
.metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.metric:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: #d1d5db; }
.metric .value { font-size: 2rem; font-weight: 800; color: var(--ink); letter-spacing: -0.03em; }
.metric .label { font-size: 0.72rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 6px; }
.cancelled-caption { font-size: 0.85rem; color: #991b1b; margin: 0 0 16px; font-weight: 600; }

.toolbar { display: flex; gap: 12px; align-items: center; margin: 24px 0; }
.toolbar input[type=search] {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}
.toolbar input[type=search]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.view-toggle a { padding: 11px 18px; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); text-decoration: none; background: transparent; transition: all 0.15s; }
.view-toggle a.active { background: var(--brand); color: #fff; }
.view-toggle a:not(.active):hover { background: var(--canvas); color: var(--ink); }
.result-count { font-size: 0.85rem; color: var(--ink-faint); margin: 0 0 16px; }

/* ---- Kanban ---- */
.kanban-board { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0,1fr)); gap: 16px; align-items: start; }
.kanban-col { background: #f9fafb; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 240px; transition: all 0.2s; }
.kanban-col.drag-over { background: var(--brand-soft); border-color: var(--brand); }
.kanban-col-title { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; display: flex; justify-content: space-between; margin: 4px 6px 12px; }
.kanban-col-title span.count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; font-weight: 700; color: var(--ink); box-shadow: var(--shadow-sm); }
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    cursor: grab;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
}
.kanban-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: #d1d5db; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .code { font-weight: 800; color: var(--brand); font-size: 0.9rem; }
.kanban-card .po { font-size: 0.72rem; color: var(--ink-faint); margin-top: 2px; }
.kanban-card .supplier { font-weight: 700; font-size: 0.85rem; margin-top: 8px; color: var(--ink); }
.kanban-card .desc { font-size: 0.78rem; margin-top: 4px; color: var(--ink-soft); line-height: 1.4; }
.kanban-card .meta { font-size: 0.72rem; color: var(--ink-faint); margin-top: 10px; }
.kanban-card .pending { font-size: 0.72rem; color: var(--warning); margin-top: 10px; border-top: 1px solid var(--border-soft); padding-top: 8px; font-weight: 600; }
.kanban-card .pending.ok { color: var(--success); }
.kanban-empty { font-size: 0.75rem; color: var(--ink-faint); padding: 8px; text-align: center; }

/* ---- Lista (Odoo style) ---- */
.odoo-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-md); }
.odoo-list-head, .odoo-list-row {
    display: grid;
    grid-template-columns: 110px 100px minmax(120px,1.2fr) minmax(150px,1.6fr) 90px 130px 120px 90px minmax(160px,1.3fr);
    gap: 0; align-items: stretch;
}
.odoo-list-head { background: #f9fafb; color: var(--ink-soft); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.odoo-list-head > div, .odoo-list-row > div { padding: 14px 12px; border-right: 1px solid var(--border-soft); overflow-wrap: anywhere; display: flex; align-items: center; }
.odoo-list-head > div:last-child, .odoo-list-row > div:last-child { border-right: 0; }
.odoo-list-row { font-size: 0.85rem; border-bottom: 1px solid var(--border-soft); background: var(--surface); transition: background 0.15s; }
.odoo-list-row:last-child { border-bottom: 0; }
.odoo-list-row:hover { background: var(--canvas); }
.odoo-code { font-weight: 800; color: var(--brand); }

.stage-pill { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--border-soft); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; text-align: center; }
.stage-en_transito { background: var(--info-soft); color: #1d4ed8; }
.stage-arribado { background: var(--warning-soft); color: #92400e; }
.stage-nacionalizado { background: var(--success-soft); color: #166534; }
.stage-terminado { background: #e5e7eb; color: var(--ink-soft); }
.stage-anulado { background: var(--danger-soft); color: #991b1b; }
.stage-enviado { background: var(--brand-soft); color: var(--brand-hover); }

.pending-flag { font-size: 0.75rem; font-weight: 600; }
.pending-flag.warn { color: var(--warning); }
.pending-flag.ok { color: var(--success); }

@media (max-width: 1100px) {
    .metrics { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .kanban-board { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
}
@media (max-width: 700px) {
    .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .kanban-board { grid-template-columns: 1fr !important; }
    .odoo-list-head { display: none; }
    .odoo-list-row { grid-template-columns: repeat(2, minmax(0,1fr)); padding: 8px; }
}

/* ============================================================================
   SaaS Professional Sidebar Layout Styles
   ============================================================================ */
.saas-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar (Dolibarr/Odoo style) */
.saas-sidebar {
    width: 260px;
    background: #1e1e2d;
    color: #a2a3b7;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 50;
}

.saas-sidebar-brand {
    height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    background: #1b1b28;
    font-weight: 800;
    color: #ffffff;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.saas-sidebar-brand svg {
    color: var(--brand);
}

.saas-sidebar-nav {
    flex: 1;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.saas-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #a2a3b7;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.saas-nav-item:hover, .saas-nav-item.active {
    color: #ffffff;
    background: #1b1b28;
    border-left-color: var(--brand);
}

.saas-nav-item svg {
    width: 20px;
    height: 20px;
    color: #494b74;
    transition: color 0.2s;
}

.saas-nav-item:hover svg, .saas-nav-item.active svg {
    color: var(--brand);
}

/* User Profile in Sidebar */
.saas-sidebar-user {
    padding: 20px 24px;
    background: #1b1b28;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.saas-sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.saas-avatar {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(79, 70, 229, 0.2);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.saas-user-details {
    display: flex;
    flex-direction: column;
}

.saas-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
}

.saas-user-role {
    font-size: 0.7rem;
    color: #a2a3b7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.saas-logout {
    color: #a2a3b7;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    background: rgba(255,255,255,0.05);
}

.saas-logout:hover {
    background: var(--danger);
    color: white;
}

/* Main Content Area */
.saas-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.saas-content {
    flex: 1;
    padding: 0 32px 32px 32px;
    overflow-y: auto;
}

/* Page Header */
.saas-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 32px 0 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-soft);
}

.saas-page-title h2 {
    font-size: 1.8rem;
    color: var(--ink);
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.saas-page-title p {
    color: var(--ink-soft);
    margin: 0;
    font-size: 0.95rem;
}

.saas-btn-action {
    background: var(--brand);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--brand-ring);
    transition: all 0.2s;
}

.saas-btn-action:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--brand-ring);
}

@media (max-width: 900px) {
    .saas-layout { flex-direction: column; }
    .saas-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; }
    .saas-sidebar-nav { display: none; }
    .saas-content { padding: 0 16px 16px 16px; }
}

/* --- Drag & Drop Dropzone --- */
.ik-dropzone {
    border: 2px dashed var(--brand);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    background: rgba(79, 70, 229, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
}
.ik-dropzone:hover, .ik-dropzone.dragover {
    background: rgba(79, 70, 229, 0.15);
    border-color: #4338ca;
}
.ik-dropzone-icon {
    font-size: 2rem;
    color: var(--brand);
    margin-bottom: 10px;
}
.ik-dropzone-text {
    font-size: 0.95rem;
    color: var(--ink);
    font-weight: 600;
}
.ik-dropzone-hint {
    font-size: 0.8rem;
    color: var(--ink-sub);
    margin-top: 4px;
}
.ik-dropzone input[type="file"] {
    display: none;
}

