/* ============================================================
   AUTOFIN CRM PRO — Estilos principales
   ============================================================ */

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

:root {
    --primary:      #1D9E75;
    --primary-dark: #0F6E56;
    --primary-light:#E1F5EE;
    --blue:         #378ADD;
    --blue-light:   #E6F1FB;
    --amber:        #BA7517;
    --amber-light:  #FAEEDA;
    --red:          #D85A30;
    --red-light:    #FAECE7;
    --purple:       #7F77DD;
    --purple-light: #EEEDFE;
    --gray-50:      #F9F9F8;
    --gray-100:     #F1EFE8;
    --gray-200:     #D3D1C7;
    --gray-400:     #888780;
    --gray-600:     #5F5E5A;
    --gray-800:     #2C2C2A;
    --white:        #FFFFFF;
    --sidebar-w:    240px;
    --topbar-h:     56px;
    --radius:       8px;
    --radius-lg:    12px;
    --shadow:       0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.1);
    --transition:   0.15s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--gray-100);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    min-height: var(--topbar-h);
}

.sidebar-logo img { width: 28px; height: 28px; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
    padding: 16px 20px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: 0;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-left-color: var(--primary);
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--gray-100);
}

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }

.logout-btn {
    color: var(--gray-400);
    text-decoration: none;
    padding: 4px;
    border-radius: var(--radius);
    display: flex;
    transition: color var(--transition);
}
.logout-btn:hover { color: var(--red); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px;
}

.page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-content { padding: 24px; }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 13px;
    font-weight: 500;
}

.flash button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.6;
}

.flash-success { background: var(--primary-light); color: var(--primary-dark); }
.flash-error   { background: var(--red-light); color: var(--red); }
.flash-warning { background: var(--amber-light); color: var(--amber); }
.flash-info    { background: var(--blue-light); color: var(--blue); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary   { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--white); color: var(--gray-600); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger  { background: var(--red-light); color: var(--red); border-color: transparent; }
.btn-danger:hover { background: var(--red); color: var(--white); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 5px;
}

.form-label .req { color: var(--red); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29,158,117,0.1);
}

.form-control::placeholder { color: var(--gray-400); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row {
    display: grid;
    gap: 16px;
}

.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

.form-hint { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 4px; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { overflow-x: auto; }

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }

.table td .text-muted { color: var(--gray-400); font-size: 12px; }

/* ============================================================
   BADGES / ESTADOS
   ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success  { background: var(--primary-light); color: var(--primary-dark); }
.badge-warning  { background: var(--amber-light); color: var(--amber); }
.badge-danger   { background: var(--red-light); color: var(--red); }
.badge-info     { background: var(--blue-light); color: var(--blue); }
.badge-secondary{ background: var(--gray-100); color: var(--gray-600); }
.badge-purple   { background: var(--purple-light); color: var(--purple); }

/* ============================================================
   STATS / KPIs
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
}

.stat-up   { color: var(--primary); }
.stat-down { color: var(--red); }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* ============================================================
   PAGINACIÓN
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    padding: 16px 0;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius);
    font-size: 13px;
    text-decoration: none;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    transition: all var(--transition);
}

.pagination a:hover { background: var(--gray-50); }
.pagination span.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination span.dots { border: none; }

/* ============================================================
   PIPELINE KANBAN
   ============================================================ */
.pipeline-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    align-items: flex-start;
}

.pipeline-col {
    min-width: 240px;
    max-width: 240px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    padding: 12px;
}

.pipeline-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.pipeline-col-name {
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stage-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pipeline-col-count {
    font-size: 11px;
    color: var(--gray-400);
    background: var(--gray-200);
    padding: 1px 7px;
    border-radius: 20px;
}

.pipeline-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }

.pipeline-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.pipeline-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.pipeline-card-title { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.pipeline-card-customer { font-size: 11px; color: var(--gray-400); margin-bottom: 6px; }

.pipeline-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--gray-400);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--gray-400);
}

.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 15px; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
    .form-row.cols-2 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.text-muted    { color: var(--gray-400); }
.text-primary  { color: var(--primary); }
.text-danger   { color: var(--red); }
.text-success  { color: var(--primary); }
.fw-500        { font-weight: 500; }
.fw-600        { font-weight: 600; }
.fs-12         { font-size: 12px; }
.fs-13         { font-size: 13px; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.mb-0          { margin-bottom: 0; }
.mb-8          { margin-bottom: 8px; }
.mb-16         { margin-bottom: 16px; }
.mb-24         { margin-bottom: 24px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
