/* ==============================================================
   estilos.css - Sistema de Gestión Empresarial
   Diseño profesional con sidebar vertical
   ============================================================== */

/* ==================== VARIABLES ==================== */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 56px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-active-bg: #334155;
    --sidebar-active-text: #ffffff;
    --sidebar-section: #64748b;
    --sidebar-brand-bg: #0f172a;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ==================== BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--body-bg);
    font-size: 14px;
    color: #334155;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

/* Brand / Logo */
.sidebar-brand {
    padding: 16px 20px;
    background: var(--sidebar-brand-bg);
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
    gap: 12px;
}

.sidebar-logo {
    height: 36px;
    width: auto;
    border-radius: 6px;
}

.sidebar-logo-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation */
.sidebar-nav {
    padding: 8px 0;
    flex: 1;
}

.sidebar-section-label {
    padding: 16px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-section);
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: all 0.15s ease;
    gap: 12px;
    position: relative;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-link i:first-child {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    font-weight: 500;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: #3b82f6;
    border-radius: 0 3px 3px 0;
}

.sidebar-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s;
}

.sidebar-link[aria-expanded="true"] .sidebar-arrow {
    transform: rotate(180deg);
}

/* Submenu */
.sidebar-submenu {
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-sublink {
    display: block;
    padding: 7px 20px 7px 52px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
}

.sidebar-sublink:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.03);
}

/* Footer del sidebar */
.sidebar-footer {
    border-top: 1px solid #334155;
    padding: 8px 0;
    flex-shrink: 0;
}

.sidebar-link-danger:hover {
    color: #fca5a5 !important;
    background: rgba(239, 68, 68, 0.1);
}

/* ==================== TOPBAR ==================== */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1030;
    transition: left 0.3s ease;
    gap: 16px;
}

.topbar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}

.topbar-toggle:hover {
    background: #f1f5f9;
    color: #334155;
}

.topbar-breadcrumb {
    flex: 1;
    font-size: 14px;
    color: #64748b;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.topbar-user {
    cursor: pointer;
}

.topbar-user > a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.topbar-user-role {
    font-size: 11px;
    color: #94a3b8;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left 0.3s ease;
}

.main-content-full {
    padding: 0;
    min-height: 100vh;
}

/* ==================== SIDEBAR COLLAPSED STATE ==================== */
.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-collapsed .topbar {
    left: 0;
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* ==================== CARDS ==================== */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: none;
}

.card:hover {
    transform: none;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
    font-size: 14px;
}

/* ====== Professional card headers: muted tinted backgrounds ====== */
.card > .card-header.bg-primary {
    background: #eff6ff !important;
    color: #1e40af !important;
    border-bottom: 2px solid #93c5fd !important;
}
.card > .card-header.bg-primary.text-white,
.card > .card-header.bg-primary h5,
.card > .card-header.bg-primary .mb-0 {
    color: #1e40af !important;
}

.card > .card-header.bg-success {
    background: #f0fdf4 !important;
    color: #166534 !important;
    border-bottom: 2px solid #86efac !important;
}
.card > .card-header.bg-success.text-white,
.card > .card-header.bg-success h5,
.card > .card-header.bg-success .mb-0 {
    color: #166534 !important;
}

.card > .card-header.bg-info {
    background: #ecfeff !important;
    color: #155e75 !important;
    border-bottom: 2px solid #67e8f9 !important;
}
.card > .card-header.bg-info.text-white,
.card > .card-header.bg-info h5,
.card > .card-header.bg-info .mb-0 {
    color: #155e75 !important;
}

.card > .card-header.bg-warning {
    background: #fefce8 !important;
    color: #854d0e !important;
    border-bottom: 2px solid #fde047 !important;
}
.card > .card-header.bg-warning.text-dark,
.card > .card-header.bg-warning.text-white,
.card > .card-header.bg-warning h5,
.card > .card-header.bg-warning .mb-0 {
    color: #854d0e !important;
}

.card > .card-header.bg-danger {
    background: #fef2f2 !important;
    color: #991b1b !important;
    border-bottom: 2px solid #fca5a5 !important;
}
.card > .card-header.bg-danger.text-white,
.card > .card-header.bg-danger h5,
.card > .card-header.bg-danger .mb-0 {
    color: #991b1b !important;
}

/* ====== Stat cards: white bg + colored left border + icon circle ====== */
.stat-card {
    background: #fff !important;
    border-left: 4px solid !important;
    color: #334155 !important;
}
.stat-card.stat-primary { border-left-color: #3b82f6 !important; }
.stat-card.stat-success { border-left-color: #22c55e !important; }
.stat-card.stat-info { border-left-color: #06b6d4 !important; }
.stat-card.stat-warning { border-left-color: #f59e0b !important; }
.stat-card.stat-danger { border-left-color: #ef4444 !important; }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-icon-primary { background: #eff6ff; color: #3b82f6; }
.stat-icon-success { background: #f0fdf4; color: #22c55e; }
.stat-icon-info { background: #ecfeff; color: #06b6d4; }
.stat-icon-warning { background: #fefce8; color: #f59e0b; }
.stat-icon-danger { background: #fef2f2; color: #ef4444; }

.stat-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

/* ====== Action cards: compact horizontal links ====== */
.action-card {
    border: 1px solid #e2e8f0;
    transition: all 0.15s ease;
    cursor: pointer;
}
.action-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.action-card .action-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.action-icon-primary { background: #eff6ff; color: #3b82f6; }
.action-icon-success { background: #f0fdf4; color: #22c55e; }
.action-icon-info { background: #ecfeff; color: #06b6d4; }
.action-icon-warning { background: #fefce8; color: #f59e0b; }

.action-card .action-text {
    font-weight: 600;
    font-size: 14px;
    color: #334155;
}

/* ====== Page headings ====== */
.page-heading {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e293b;
}
.page-heading i {
    color: #64748b;
    font-size: 1.1rem;
}

/* ==================== TABLES ==================== */
.table th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
}

.table td {
    vertical-align: middle;
    color: #334155;
}

.table-responsive {
    border-radius: 0 0 10px 10px;
}

/* ==================== BADGES ==================== */
.badge {
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ==================== FORMS ==================== */
.form-control, .form-select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 13px;
    color: #475569;
}

/* ==================== BUTTONS ==================== */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
}

.btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* ==================== ALERTS ==================== */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 14px;
}

/* ==================== LINES COMPRA/VENTA ==================== */
.linea-compra td,
.linea-venta td {
    padding: 0.4rem;
}

.linea-compra .form-control,
.linea-compra .form-select,
.linea-venta .form-control,
.linea-venta .form-select {
    font-size: 13px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .has-sidebar:not(.sidebar-collapsed) .sidebar {
        transform: translateX(0);
    }

    .topbar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    /* Overlay cuando sidebar está abierta en móvil */
    .has-sidebar:not(.sidebar-collapsed)::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1035;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .display-5 {
        font-size: 1.5rem;
    }
    .display-6 {
        font-size: 1.2rem;
    }
}

/* ==================== PRINT ==================== */
@media print {
    .sidebar, .topbar, footer, .btn, .alert {
        display: none !important;
    }
    .main-content {
        margin: 0;
        padding: 0;
    }
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}
