/* ============================================================================
   DevPlanner — Design System
   Heredado de borbalan-works, adaptado a DevPlanner (multi-promoción).
   Inter font · minimal · Bootstrap 5.3.3 compatible.
   ============================================================================ */

/* ---------- Variables ---------- */
:root {
    --text-primary:   #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted:     #9ca3af;
    --border:         #e5e7eb;
    --bg-white:       #ffffff;
    --bg-light:       #f9fafb;
    --bg-hover:       #f3f4f6;
    --accent:         #1a1a1a;
    --accent-hover:   #374151;
    --green:          #059669;
    --red:            #dc2626;
    --blue:           #2563eb;
    --yellow:         #d97706;
    --purple:         #7c3aed;
    --orange:         #ea580c;
    --radius:         6px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: Inter, -apple-system, "system-ui", "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-primary); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 0;
}
h4 { font-size: 1.25rem; }

.text-muted, small.text-muted { color: var(--text-secondary) !important; }

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ---------- Topbar ---------- */
.topbar {
    position: fixed;
    top: 0;
    left: 220px;
    right: 0;
    height: 48px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1030;
}
.topbar-brand {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}
.topbar-link {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}
.topbar-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    padding: 4px 8px;
    cursor: pointer;
    margin-right: 8px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sidebar-brand {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-brand a {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.sidebar-nav { padding: 8px 0; flex: 1; }
.sidebar-section {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 16px 16px 4px;
}
.sidebar-section:first-child { padding-top: 8px; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-link.active {
    background: var(--bg-light);
    color: var(--text-primary);
    font-weight: 500;
    border-left-color: var(--text-primary);
}
.sidebar-link i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1035;
}

/* ---------- Buttons ---------- */
.btn-dp {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.btn-dp:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-outline-dp {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 400;
    padding: 6px 16px;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.btn-outline-dp:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-secondary); }

.btn-xs { padding: 3px 8px; font-size: 12px; line-height: 1.4; border-radius: 4px; }
.btn-sm { font-size: 13px; padding: 5px 14px; border-radius: var(--radius); }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none;
}
.card-header {
    background: var(--bg-light) !important;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 10px 16px;
}
.card-body { padding: 16px; }

/* KPI cards */
.kpi-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    padding: 16px 12px;
    background: var(--bg-white);
    transition: background 0.15s;
}
.kpi-card:hover { background: var(--bg-light); }
.kpi-card .kpi-label {
    font-size: 11.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.kpi-card .kpi-value.green  { color: var(--green); }
.kpi-card .kpi-value.blue   { color: var(--blue); }
.kpi-card .kpi-value.red    { color: var(--red); }
.kpi-card .kpi-value.yellow { color: var(--yellow); }

/* ---------- Tables ---------- */
.table { font-size: 13px; margin-bottom: 0; }
.table thead th {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    white-space: nowrap;
}
.table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.table a.row-link { color: var(--text-primary); font-weight: 500; }
.table a.row-link:hover { text-decoration: underline; }

/* ---------- Tags / Badges ---------- */
.tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    line-height: 1.5;
    white-space: nowrap;
}

.tag-success  { background: #d1fae5; color: #065f46; }
.tag-info     { background: #dbeafe; color: #1e40af; }
.tag-warning  { background: #fef3c7; color: #92400e; }
.tag-purple   { background: #ede9fe; color: #5b21b6; }
.tag-olive    { background: #fef9c3; color: #854d0e; }
.tag-danger   { background: #fee2e2; color: #991b1b; }
.tag-secondary{ background: #f3f4f6; color: #6b7280; }

/* Role badges */
.tag-rol              { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 3px; color: #fff; }
.tag-rol.superadmin   { background: #1a1a1a; }
.tag-rol.socio        { background: #2563eb; }
.tag-rol.tecnico      { background: #059669; }

/* ---------- Monday-style color pills ---------- */
.monday-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    text-align: center;
    min-width: 70px;
    line-height: 20px;
    position: relative;
    transition: opacity 0.15s;
}
.monday-pill:hover { opacity: 0.85; }
.monday-pill.empty { background: #c4c4c4; color: #fff; cursor: default; }

/* --- Estados promoción --- */
.pill-planificacion    { background: #94a3b8; }
.pill-adquisicion      { background: #fdab3d; }
.pill-obra             { background: #2563eb; }
.pill-comercializacion { background: #9d50dd; }
.pill-entrega          { background: #059669; }
.pill-cerrado          { background: #475569; }

/* --- Estados parcela --- */
.pill-pendiente   { background: #fdab3d; }
.pill-en-obra     { background: #2563eb; }
.pill-finalizada  { background: #059669; }
.pill-entregada   { background: #037f4c; }

/* --- Estados documento --- */
.pill-borrador    { background: #94a3b8; }
.pill-revision    { background: #fdab3d; }
.pill-validado    { background: #059669; }
.pill-superseded  { background: #cbd5e1; color: #475569; }
.pill-archivado   { background: #64748b; }

/* --- Estados acción --- */
.pill-en-curso    { background: #2563eb; }
.pill-completada  { background: #059669; }
.pill-cancelada   { background: #cbd5e1; color: #475569; }

/* --- Estados financiero --- */
.pill-pagado      { background: #059669; }
.pill-vencido     { background: #dc2626; }
.pill-cancelado   { background: #cbd5e1; color: #475569; }

/* --- Estados hito --- */
.pill-completado  { background: #059669; }
.pill-bloqueado   { background: #dc2626; }

/* --- Prioridades acción --- */
.pill-baja        { background: #94a3b8; }
.pill-media       { background: #2563eb; }
.pill-alta        { background: #ea580c; }
.pill-urgente     { background: #dc2626; }

/* --- Severidades discrepancia --- */
.pill-info        { background: #2563eb; }
.pill-critica     { background: #991b1b; }

/* --- Clasificación email --- */
.pill-certificacion { background: #059669; }
.pill-presupuesto   { background: #fdab3d; }
.pill-plano         { background: #2563eb; }
.pill-legal         { background: #7c3aed; }
.pill-financiero    { background: #dc2626; }
.pill-coordinacion  { background: #ea580c; }
.pill-acta          { background: #0891b2; }
.pill-decision      { background: #d97706; }
.pill-informativo   { background: #94a3b8; }
.pill-otro          { background: #cbd5e1; color: #475569; }

/* ---------- Filtros ---------- */
.filtros-bar {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--bg-white);
}

/* ---------- Forms ---------- */
.form-control,
.form-select {
    font-size: 13.5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 6px 12px;
    transition: border-color 0.15s;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--text-secondary);
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.1);
}
.form-control-sm, .form-select-sm { font-size: 13px; padding: 5px 10px; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* ---------- Progress ---------- */
.progress {
    height: 16px;
    background: var(--bg-light);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-dp { background: var(--text-primary); border-radius: 3px; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
}
.login-box {
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.04);
}
.login-box .login-logo {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 20px;
}
.login-box h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.login-box .login-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}
.login-box .form-group { margin-bottom: 18px; }
.login-box .form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.login-box .input-icon-wrap { position: relative; }
.login-box .input-icon-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
    pointer-events: none;
}
.login-box .input-icon-wrap .form-control { padding-left: 38px; width: 100%; }
.login-box .input-icon-wrap .toggle-pw {
    position: absolute;
    right: 12px; left: auto;
    top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    pointer-events: auto;
    z-index: 2;
}
.login-box .input-icon-wrap .toggle-pw:hover { color: var(--text-primary); }
.login-box .form-control {
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26,26,26,0.08);
}
.login-box .btn-dp {
    width: 100%;
    padding: 11px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    margin-top: 4px;
}
.login-box .login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}
.login-box .alert {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* ---------- Detalle vista ---------- */
.detalle-label {
    font-size: 11.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.detalle-value { font-size: 13.5px; color: var(--text-primary); }
.detalle-value.big { font-size: 18px; font-weight: 600; }

/* ---------- Timeline ---------- */
.historial-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.historial-item:last-child { border-bottom: none; }
.historial-fecha { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Pagination ---------- */
.pagination .page-link {
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 4px 10px;
    margin: 0 2px;
    border-radius: 4px;
}
.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.pagination .page-link:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---------- Dropdown ---------- */
.dropdown-menu {
    font-size: 13px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-radius: var(--radius);
}

/* ---------- Modal ---------- */
.modal-content {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 20px; }

/* ---------- Alerts ---------- */
.alert {
    font-size: 13px;
    border-radius: var(--radius);
    padding: 10px 16px;
}

/* ---------- Separadores ---------- */
hr, .divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- Layout ---------- */
.main-content {
    margin-left: 220px;
    padding: 64px 24px 24px;
    min-height: 100vh;
}
.main-footer {
    margin-left: 220px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 12px 24px 16px;
}
main.container-fluid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 68px 24px 24px;
}

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Code ---------- */
code {
    font-family: "SF Mono", Menlo, monospace;
    font-size: 12px;
    background: var(--bg-light);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--text-secondary);
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .topbar { left: 0; }
    .main-content { margin-left: 0; padding: 60px 16px 16px; }
    .main-footer { margin-left: 0; }
}
@media (max-width: 768px) {
    .main-content { padding: 56px 12px 16px; }
    .table { font-size: 12px; }
    .table thead th, .table tbody td { padding: 8px 8px; }
    .filtros-bar { padding: 10px 12px; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================================================
   Chat IA (preparado para Fase 4)
   ============================================================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.chat-container-sidebar { height: 500px; }
.chat-container-full { height: calc(100vh - 140px); max-height: 700px; }
.chat-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
    font-size: 13px;
    flex-shrink: 0;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-welcome { text-align: center; padding: 40px 20px; margin: auto 0; }
.chat-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}
.chat-bubble pre {
    margin: 6px 0;
    padding: 8px;
    background: rgba(0,0,0,0.04);
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
}
.chat-bubble code {
    font-size: 12px;
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 3px;
}
.chat-bubble pre code { background: none; padding: 0; }
.chat-bubble-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble-assistant {
    align-self: flex-start;
    background: var(--bg-light);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-bubble-error {
    align-self: center;
    background: #fee2e2;
    color: #991b1b;
    font-size: 12px;
}
.chat-input-area {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
}
.chat-textarea { resize: none; font-size: 13px; min-height: 36px; max-height: 120px; }
.chat-typing { display: flex; gap: 4px; padding: 4px 0 8px; align-items: center; }
.chat-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chatTyping 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}
