/* ============================================================
   GALLAECIA CRM - Estilos Principales
   ============================================================ */

:root {
    --primary:    #1a3a5c;
    --primary-light: #234e7a;
    --primary-dark: #102640;
    --success:    #2ecc71;
    --success-dark: #27ae60;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font-main);
    background: #f0f4f8;
    color: #2d3748;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }

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

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 20px 20px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    background: var(--success);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 900;
    color: white;
    flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text .name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.sidebar-brand-text .sub {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 400;
}

.sidebar-section-title {
    padding: 14px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

.sidebar-nav { padding: 8px 0; flex: 1; }
.sidebar-nav .nav-item { margin: 1px 10px; }
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,0.75);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}
.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateX(2px);
}
.sidebar-nav .nav-link.active {
    background: var(--success);
    color: #fff;
    box-shadow: 0 2px 8px rgba(46,204,113,0.35);
}
.sidebar-nav .nav-link i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-nav .badge-count {
    margin-left: auto;
    background: rgba(255,255,255,0.2);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
}
.sidebar-nav .nav-link.active .badge-count {
    background: rgba(0,0,0,0.2);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.85);
    font-size: 13px;
}
.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user-info .user-name { font-weight: 600; line-height: 1.2; }
.sidebar-user-info .user-role {
    font-size: 11px;
    opacity: 0.6;
    text-transform: capitalize;
}

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

/* ── TOPBAR ── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
    gap: 16px;
}
.topbar-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--primary);
}
.topbar-breadcrumb {
    flex: 1;
    font-size: 13px;
    color: #718096;
}
.topbar-breadcrumb .current {
    color: var(--primary);
    font-weight: 600;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #718096;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}
.topbar-btn:hover { background: #f7fafc; color: var(--primary); }
.topbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #e53e3e;
    color: white;
    font-size: 9px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ── PAGE CONTENT ── */
.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 4px;
}
.page-subtitle {
    font-size: 13px;
    color: #718096;
    margin: 0;
}

/* ── CARDS ── */
.card {
    background: #fff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
    margin-bottom: 24px;
}
.card-header {
    background: none;
    border-bottom: 1px solid #f0f4f8;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h5, .card-header h6 {
    margin: 0;
    font-weight: 600;
    color: var(--primary);
}
.card-body { padding: 20px; }

/* ── STAT CARDS (Dashboard) ── */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s;
    text-decoration: none;
    color: inherit;
    border-left: 4px solid transparent;
}
.stat-card:hover { transform: translateY(-2px); color: inherit; }
.stat-card.primary   { border-left-color: var(--primary); }
.stat-card.success   { border-left-color: var(--success); }
.stat-card.warning   { border-left-color: #f6ad55; }
.stat-card.danger    { border-left-color: #fc8181; }
.stat-card.info      { border-left-color: #63b3ed; }
.stat-card.purple    { border-left-color: #9f7aea; }

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}
.stat-card.primary .stat-icon   { background: #ebf4ff; color: var(--primary); }
.stat-card.success .stat-icon   { background: #f0fff4; color: var(--success-dark); }
.stat-card.warning .stat-icon   { background: #fffaf0; color: #dd6b20; }
.stat-card.danger  .stat-icon   { background: #fff5f5; color: #c53030; }
.stat-card.info    .stat-icon   { background: #ebf8ff; color: #2b6cb0; }
.stat-card.purple  .stat-icon   { background: #faf5ff; color: #6b46c1; }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: #1a202c;
}
.stat-label {
    font-size: 13px;
    color: #718096;
    margin-top: 2px;
}

/* ── TABLES ── */
.table-crm { font-size: 13.5px; }
.table-crm thead th {
    background: #f7fafc;
    color: #4a5568;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.table-crm tbody tr:hover { background: #f7fafc; }
.table-crm td { vertical-align: middle; }

/* ── FORMS ── */
.form-label { font-weight: 500; font-size: 13px; color: #4a5568; margin-bottom: 4px; }
.form-control, .form-select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13.5px;
    padding: 8px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}
.input-group .form-control:focus { z-index: 1; }

/* ── BUTTONS ── */
.btn { border-radius: 8px; font-size: 13.5px; font-weight: 500; padding: 8px 16px; }
.btn-primary  { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-success  { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: var(--success-dark); border-color: var(--success-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ── BADGES ── */
.badge { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 6px; }

/* ── ALERTS / FLASH ── */
.alert { border-radius: 10px; font-size: 13.5px; }
.alert-success { background: #f0fff4; color: #276749; border-color: #9ae6b4; }
.alert-danger  { background: #fff5f5; color: #742a2a; border-color: #feb2b2; }
.alert-warning { background: #fffaf0; color: #744210; border-color: #fbd38d; }
.alert-info    { background: #ebf8ff; color: #2a4365; border-color: #90cdf4; }

/* ── CALENDAR ── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.calendar-day-header {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #718096;
    padding: 8px 0;
}
.calendar-day {
    min-height: 80px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}
.calendar-day:hover { background: #f7fafc; }
.calendar-day.today { border-color: var(--primary); background: #ebf4ff; }
.calendar-day.other-month { opacity: 0.4; }
.calendar-day .day-number {
    font-weight: 700;
    font-size: 13px;
    color: #2d3748;
}
.calendar-day.today .day-number { color: var(--primary); }
.calendar-day.holiday { background: #fff5f5; border-color: #feb2b2; }
.calendar-event {
    margin-top: 2px;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calendar-event.vacation { background: #c6f6d5; color: #276749; }
.calendar-event.contract { background: #bee3f8; color: #2a4365; }
.calendar-event.task { background: #fbd38d; color: #744210; }

/* ── PROGRESS BARS ── */
.progress { height: 6px; border-radius: 3px; }
.progress-bar { border-radius: 3px; }

/* ── TIMELINE / HISTORY ── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
    position: absolute;
    left: -22px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}
.timeline-date { font-size: 11px; color: #718096; margin-bottom: 4px; }
.timeline-content {
    background: #f7fafc;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
}

/* ── NOTE CARDS ── */
.note-card {
    border-radius: 10px;
    padding: 16px;
    border-left: 4px solid;
    font-size: 13.5px;
    position: relative;
}
.note-card.blue  { background: #ebf8ff; border-color: #63b3ed; }
.note-card.green { background: #f0fff4; border-color: #68d391; }
.note-card.yellow{ background: #fffff0; border-color: #f6e05e; }
.note-card.red   { background: #fff5f5; border-color: #fc8181; }
.note-pin { position: absolute; top: 10px; right: 10px; color: #718096; font-size: 14px; }
.note-pin.active { color: var(--primary); }

/* ── SEARCH / FILTER BAR ── */
.filter-bar {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* ── CHIPS ── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.chip-primary { background: #ebf4ff; color: var(--primary); }
.chip-success { background: #f0fff4; color: var(--success-dark); }
.chip-warning { background: #fffaf0; color: #dd6b20; }
.chip-danger  { background: #fff5f5; color: #c53030; }

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #1a5276 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 900;
    color: white;
    margin: 0 auto 12px;
}
.login-logo h2 {
    color: var(--primary);
    font-weight: 800;
    font-size: 24px;
    margin: 0;
    letter-spacing: 1px;
}
.login-logo p { color: #718096; font-size: 13px; margin: 4px 0 0; }
.login-card .form-control {
    height: 46px;
    font-size: 14px;
    padding-left: 42px;
}
.login-input-wrap { position: relative; }
.login-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
    font-size: 16px;
    z-index: 2;
}
.btn-login {
    height: 46px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state h6 { color: #718096; font-weight: 600; }
.empty-state p { font-size: 13px; }

/* ── VENCIMIENTO ALERT ── */
.venc-urgent { color: #c53030; font-weight: 600; }
.venc-soon   { color: #dd6b20; font-weight: 600; }
.venc-ok     { color: #276749; }

/* ── AVATAR ── */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

/* ── RESPONSIVE ── */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar-toggle { display: flex; }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    .sidebar-overlay.show { display: block; }
}
@media (max-width: 768px) {
    .page-content { padding: 16px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .filter-bar { flex-direction: column; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .page-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    /* Tablas sin .table-responsive: scroll horizontal automático */
    .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .card .table-responsive table { display: table; }
    /* Objetivos táctiles más cómodos */
    .btn-xs { padding: 4px 10px; }
    .nav-link { padding: 11px 16px; }
    .page-title { font-size: 20px; }
    .breadcrumb { font-size: 12px; }
}

/* ── PRINT ── */
@media print {
    .sidebar, .topbar { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ── MISC UTILITIES ── */
.cursor-pointer { cursor: pointer; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.fw-600 { font-weight: 600; }
.fs-13 { font-size: 13px; }
.gap-2 { gap: 8px; }
.rounded-10 { border-radius: 10px; }
.bg-primary-subtle { background: #ebf4ff; }
.border-primary { border-color: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }
.bg-crm-primary { background: var(--primary) !important; }
