/* ============================================
   RETAIL - Color Palette & Variables
   ============================================ */
:root {
    --primary: #FF6B00;
    --gradient-1: #FF8A00;
    --gradient-2: #FF4500;
    --black-corporate: #111827;
    --gray-dark: #374151;
    --bg: #F8FAFC;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --success: #22C55E;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    --sidebar-width: 240px;
}

/* ============================================
   Base Styles
   ============================================ */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--black-corporate);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

a {
    text-decoration: none;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
    max-width: 140px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    list-style: none;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-dark);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background-color: #FFF7ED;
    color: var(--primary);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--gradient-2));
    color: var(--white);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
    margin-right: 8px;
}

.sidebar-nav .nav-link i,
.sidebar-nav .nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--gradient-2));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info .name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--black-corporate);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .branch {
    font-size: 0.75rem;
    color: var(--gray-dark);
}

.sidebar-user-info .status {
    font-size: 0.7rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-user-info .status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--success);
    display: inline-block;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Top Header
   ============================================ */
.top-header {
    background-color: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
}

.top-header .page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--black-corporate);
    margin: 0;
}

.top-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--white);
    color: var(--black-corporate);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.company-selector:hover {
    border-color: var(--primary);
}

.notification-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-dark);
}

.notification-btn:hover {
    background-color: #FFF7ED;
    color: var(--primary);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--error);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gray-dark), var(--black-corporate));
    color: var(--white);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ============================================
   Dashboard Content
   ============================================ */
.dashboard-content {
    padding: 32px;
    flex: 1;
}

.welcome-section {
    margin-bottom: 24px;
}

.welcome-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--black-corporate);
    margin: 0 0 4px 0;
}

.welcome-section p {
    color: var(--gray-dark);
    margin: 0;
    font-size: 0.9rem;
}

.welcome-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.date-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    font-size: 0.85rem;
    color: var(--black-corporate);
    cursor: pointer;
}

.date-selector:hover {
    border-color: var(--primary);
}

/* ============================================
   Stats Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.5rem;
}

.stat-icon.products {
    background-color: #FFF7ED;
    color: var(--primary);
}

.stat-icon.stock {
    background-color: #F0FDF4;
    color: var(--success);
}

.stat-icon.sales {
    background-color: #EFF6FF;
    color: var(--info);
}

.stat-icon.invoices {
    background-color: #F5F3FF;
    color: #8B5CF6;
}

.stat-icon.low-stock {
    background-color: #FEF3C7;
    color: var(--warning);
}

.stat-info .stat-label {
    font-size: 0.8rem;
    color: var(--gray-dark);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-info .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--black-corporate);
    line-height: 1.2;
}

.stat-info .stat-sublabel {
    font-size: 0.75rem;
    font-weight: 600;
}

.stat-sublabel.active {
    color: var(--primary);
}

.stat-sublabel.units {
    color: var(--success);
}

.stat-sublabel.transactions {
    color: var(--info);
}

.stat-sublabel.issued {
    color: #8B5CF6;
}

.stat-sublabel.products-warn {
    color: var(--warning);
}

/* ============================================
   Charts Section
   ============================================ */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--black-corporate);
    margin: 0;
}

.chart-filter {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--gray-dark);
    background: var(--white);
    cursor: pointer;
}

.chart-placeholder {
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-dark);
    font-size: 0.9rem;
}

/* Pie chart legend */
.pie-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pie-center-text {
    text-align: center;
}

.pie-center-text .amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--black-corporate);
}

.pie-center-text .label {
    font-size: 0.8rem;
    color: var(--gray-dark);
}

.pie-legend {
    width: 100%;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.pie-legend-item:last-child {
    border-bottom: none;
}

.pie-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pie-legend-info .branch-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--black-corporate);
}

.pie-legend-info .branch-detail {
    font-size: 0.75rem;
    color: var(--gray-dark);
}

/* ============================================
   Tables Section
   ============================================ */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.table-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--black-corporate);
    margin: 0;
}

.btn-view-all {
    padding: 6px 16px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background: var(--white);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-view-all:hover {
    background: var(--primary);
    color: var(--white);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px;
    font-size: 0.85rem;
    color: var(--black-corporate);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.product-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--gray-dark);
}

/* Status badges */
.badge-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-critical {
    background-color: #FEE2E2;
    color: var(--error);
}

.badge-low {
    background-color: #FEF3C7;
    color: #D97706;
}

.badge-entry {
    background-color: #FEE2E2;
    color: var(--error);
}

.badge-exit {
    background-color: #DCFCE7;
    color: var(--success);
}

.badge-entrada {
    background-color: #DCFCE7;
    color: var(--success);
}

.badge-salida {
    background-color: #FEE2E2;
    color: var(--error);
}

/* ============================================
   Focus & Form Styles
   ============================================ */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #FF6B00;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .tables-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-content {
        padding: 16px;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}