/* ============================================
   GestiónPro — Estilos Principales
   ============================================ */

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

:root {
    --primary:       #4F46E5;
    --primary-dark:  #3730A3;
    --primary-light: #EEF2FF;
    --accent:        #06B6D4;
    --success:       #10B981;
    --warning:       #F59E0B;
    --danger:        #EF4444;
    --gray-50:       #F9FAFB;
    --gray-100:      #F3F4F6;
    --gray-200:      #E5E7EB;
    --gray-400:      #9CA3AF;
    --gray-600:      #4B5563;
    --gray-800:      #1F2937;
    --sidebar-w:     240px;
    --radius:        10px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
    --shadow-lg:     0 10px 40px rgba(0,0,0,.12);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.6;
}

/* ====== LOGIN ====== */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 70%, #06B6D4 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: rgba(255,255,255,.04);
    border-radius: 50%;
    top: -200px; left: -200px;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(6,182,212,.1);
    border-radius: 50%;
    bottom: -100px; right: -100px;
}
.login-box {
    margin: auto;
    background: #fff;
    border-radius: 20px;
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.login-logo p  { font-size: 13px; color: var(--gray-400); margin-top: 2px; }
.login-box h2  { font-size: 18px; font-weight: 600; margin-bottom: 24px; }

/* ====== LAYOUT ====== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ====== SIDEBAR ====== */
.sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--gray-100);
}
.brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.brand-name { font-size: 16px; font-weight: 700; color: var(--gray-800); }

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--gray-600);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.user-details { flex: 1; overflow: hidden; }
.user-name  { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 11px; color: var(--gray-400); }
.logout-btn { text-decoration: none; font-size: 18px; color: var(--gray-400); transition: color .15s; }
.logout-btn:hover { color: var(--danger); }

/* ====== MAIN CONTENT ====== */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.top-bar {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 17px; font-weight: 600; color: var(--gray-800); }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-600); }
.page-content { padding: 28px; flex: 1; }

/* ====== CARDS ====== */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    border: 1px solid var(--gray-100);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; }

/* ====== STAT CARDS ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 22px;
    border: 1px solid var(--gray-100);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--gray-400); margin-top: 2px; font-weight: 500; }

/* ====== PROYECTOS GRID (dashboard) ====== */
.proyectos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}
.proyecto-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow .2s, transform .2s;
    text-decoration: none;
    color: inherit;
}
.proyecto-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.pc-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pc-nombre { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.pc-cliente { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.pc-montos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pc-monto-item { background: var(--gray-50); border-radius: 8px; padding: 10px 12px; }
.pc-monto-label { font-size: 10px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.pc-monto-value { font-size: 15px; font-weight: 700; margin-top: 2px; }
.pc-progress { }
.pc-progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--gray-400); margin-bottom: 5px; }
.progress-bar { height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.fill-green  { background: linear-gradient(90deg, var(--success), #34D399); }
.fill-yellow { background: linear-gradient(90deg, var(--warning), #FCD34D); }
.fill-red    { background: linear-gradient(90deg, var(--danger), #FC8181); }
.fill-blue   { background: linear-gradient(90deg, var(--primary), var(--accent)); }

/* ====== FORMS ====== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .4px; }
input, select, textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-800);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
textarea { resize: vertical; min-height: 80px; }

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: filter .15s, transform .1s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost   { background: var(--gray-100); color: var(--gray-800); border: 1.5px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ====== TABLES ====== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--gray-50); color: var(--gray-600); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
.td-actions { display: flex; gap: 6px; }

/* ====== ALERTS ====== */
.alert {
    padding: 13px 18px;
    border-radius: 8px;
    margin: 0 28px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
}
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #C7D2FE; }
.alert-close   { background: none; border: none; font-size: 18px; cursor: pointer; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* ====== BADGES ====== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }

/* ====== EMPTY STATE ====== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; margin-bottom: 20px; }

/* ====== DETAIL PAGE ====== */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--gray-100); font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--gray-400); font-weight: 500; }
.info-value { font-weight: 600; text-align: right; }
.balance-box { border-radius: 10px; padding: 18px; margin-bottom: 12px; }
.balance-box.green  { background: #DCFCE7; }
.balance-box.red    { background: #FEE2E2; }
.balance-box.blue   { background: var(--primary-light); }
.balance-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; opacity: .7; }
.balance-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.balance-sub   { font-size: 12px; margin-top: 2px; opacity: .7; }

/* ====== MODAL ====== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:translateY(-12px); } to { opacity:1; transform:translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal-title  { font-size: 16px; font-weight: 700; }
.modal-close  { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-400); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ====== SIDEBAR BACKDROP (mobile) ====== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 90;
}
.sidebar-backdrop.show { display: block; }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid.cols-3 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .proyectos-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}
