/* ============================================================
   SGCD - Sistema de Gestion, Control y Distribucion de Lacteos
   powered by Insighbox & Corp-BID
   Admin Dashboard Theme (NiceAdmin-inspired)
   ============================================================ */

:root {
    /* Primary Colors */
    --primary: #4154f1;
    --primary-dark: #3648d4;
    --primary-light: #6b7bfd;
    --primary-rgb: 65, 84, 241;

    /* Secondary */
    --secondary: #6c757d;
    --success: #0dcaf0;
    --success-dark: #0bacbe;
    --info: #0d6efd;
    --warning: #ffc107;
    --warning-dark: #e6ad06;
    --danger: #dc3545;
    --danger-dark: #b92d3a;

    /* SGCD Brand (Milking Distribuidora) */
    --brand-blue: #002978;
    --brand-orange: #ff8c00;
    --brand-green: #28a745;

    /* Backgrounds */
    --body-bg: #f6f9ff;
    --card-bg: #ffffff;
    --sidebar-bg: #002978;
    --sidebar-hover: rgba(255,255,255,0.12);
    --sidebar-active: rgba(255,140,0,0.25);
    --header-bg: #ffffff;

    /* Text */
    --text-dark: #012970;
    --text-muted: #6c757d;
    --text-light: #ffffff;

    /* Borders */
    --border-color: #e2e5ec;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 2px 6px rgba(1, 41, 112, 0.06);
    --shadow-md: 0 4px 16px rgba(1, 41, 112, 0.08);
    --shadow-lg: 0 8px 30px rgba(1, 41, 112, 0.1);

    /* Transitions */
    --transition: all 0.3s ease;

    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-collapsed: 60px;

    /* Font */
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background: var(--body-bg);
    color: #444444;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

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

.main-panel {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    flex: 1;
    padding: 24px 28px;
    padding-top: 88px;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0; top: 0;
    z-index: 1040;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 72px;
}

.sidebar-brand img {
    height: 42px;
    width: auto;
    border-radius: 8px;
    background: #fff;
    padding: 4px 8px;
}

.sidebar-brand h4 {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.3;
}

.sidebar-brand h4 span {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Nav Section Title */
.nav-section-title {
    padding: 16px 24px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
}

/* Nav Item */
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    position: relative;
    gap: 12px;
}

.nav-item i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: var(--brand-orange);
}

.nav-item.active {
    color: #fff;
    background: rgba(255, 140, 0, 0.18);
    border-left-color: var(--brand-orange);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand-orange);
}

/* ===== TOP HEADER ===== */
.top-header {
    height: 64px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tasa Badge */
.tasa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--success-dark), var(--success));
    color: #fff;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.tasa-badge i { font-size: 13px; }

/* Header Icon Buttons */
.header-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--body-bg);
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    font-size: 16px;
}

.header-btn:hover { background: var(--primary); color: #fff; }

.header-btn .badge-count {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* User Dropdown */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-dropdown:hover { background: var(--body-bg); }

.user-dropdown img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-dropdown .user-info { line-height: 1.3; }
.user-dropdown .user-info .name { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.user-dropdown .user-info .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ===== BREADCRUMB ===== */
.breadcrumb-container {
    margin-bottom: 20px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .active { color: var(--text-dark); font-weight: 600; }
.breadcrumb i { font-size: 10px; color: #adb5bd; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.page-header h1 i { color: var(--primary); margin-right: 10px; }

/* ===== CARDS ===== */
.m-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition);
}

.m-card:hover { box-shadow: var(--shadow-md); }

.m-card-header {
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: #fafbfd;
}

.m-card-header h5 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.m-card-header h5 i { color: var(--primary); font-size: 16px; }

.m-card-body { padding: 24px; }

/* ===== KPI CARDS ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.kpi-card.primary::before { background: var(--primary); }
.kpi-card.success::before { background: var(--success-dark); }
.kpi-card.warning::before { background: var(--warning-dark); }
.kpi-card.danger::before { background: var(--danger-dark); }
.kpi-card.info::before { background: var(--info); }
.kpi-card.brand::before { background: var(--brand-orange); }

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.kpi-card.primary .kpi-icon { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.kpi-card.success .kpi-icon { background: rgba(13, 202, 240, 0.1); color: var(--success-dark); }
.kpi-card.warning .kpi-icon { background: rgba(255, 193, 7, 0.1); color: var(--warning-dark); }
.kpi-card.danger .kpi-icon { background: rgba(220, 53, 69, 0.1); color: var(--danger-dark); }
.kpi-card.info .kpi-icon { background: rgba(13, 110, 253, 0.1); color: var(--info); }
.kpi-card.brand .kpi-icon { background: rgba(255, 140, 0, 0.1); color: var(--brand-orange); }

.kpi-content { flex: 1; }
.kpi-content h6 { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.kpi-content .kpi-value { font-size: 24px; font-weight: 700; color: var(--text-dark); line-height: 1.2; }
.kpi-content .kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== TABLES ===== */
.m-table { width: 100%; border-collapse: separate; border-spacing: 0; }

.m-table thead th {
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    background: #f8f9fa;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.m-table thead th:first-child { border-radius: 6px 0 0 0; }
.m-table thead th:last-child { border-radius: 0 6px 0 0; }

.m-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    vertical-align: middle;
}

.m-table tbody tr { transition: var(--transition); }
.m-table tbody tr:hover { background: #f8faff; }

.m-table tbody tr:last-child td { border-bottom: none; }

/* ===== FORMS ===== */
.m-form-group { margin-bottom: 18px; }

.m-form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
}

.m-input {
    width: 100%;
    padding: 10px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    color: #444;
    background: #fff;
    transition: var(--transition);
}

.m-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

.m-input::placeholder { color: #adb5bd; }

select.m-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

textarea.m-input { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

/* ===== BUTTONS ===== */
.btn-m {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-m:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-m:active { transform: translateY(0); }

.btn-m-primary { background: var(--primary); color: #fff; }
.btn-m-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-m-success { background: var(--success-dark); color: #fff; }
.btn-m-success:hover { background: #0a9ba8; color: #fff; }

.btn-m-danger { background: var(--danger); color: #fff; }
.btn-m-danger:hover { background: var(--danger-dark); color: #fff; }

.btn-m-warning { background: var(--warning); color: #212529; }
.btn-m-warning:hover { background: var(--warning-dark); color: #212529; }

.btn-m-secondary { background: #e9ecef; color: #495057; }
.btn-m-secondary:hover { background: #dee2e6; color: #212529; }

.btn-m-sm { padding: 6px 14px; font-size: 12px; }
.btn-m-lg { padding: 14px 28px; font-size: 15px; }
.btn-m-icon { padding: 8px; width: 36px; height: 36px; }

.btn-group-m { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== BADGES ===== */
.badge-m {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f3f4f6; color: #4b5563; }
.badge-primary { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }

/* ===== ALERTS ===== */
.m-alert {
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.m-alert i { font-size: 18px; flex-shrink: 0; }
.m-alert-danger { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.m-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.m-alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.m-alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== TABS ===== */
.m-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
}

.m-tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    font-family: var(--font-family);
}

.m-tab-btn:hover { color: var(--primary); }
.m-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.m-tab-panel { display: none; }
.m-tab-panel.active { display: block; }

/* ===== FLASH ===== */
.flash-msg {
    position: fixed;
    top: 80px;
    right: 28px;
    padding: 16px 24px;
    border-radius: var(--border-radius);
    color: #fff;
    font-weight: 600;
    z-index: 9999;
    animation: slideInRight 0.3s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
}

.flash-msg.success { background: linear-gradient(135deg, #059669, #10b981); }
.flash-msg.error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.flash-msg.warning { background: linear-gradient(135deg, #d97706, #f59e0b); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== LOGIN ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #002978 0%, #001a4d 50%, #002978 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    top: -100px;
    right: -100px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255, 140, 0, 0.12);
    bottom: -50px;
    left: -50px;
}

.login-card {
    background: #fff;
    border-radius: var(--border-radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-card .login-logo img {
    height: 70px;
    margin-bottom: 12px;
}

.login-card .login-logo h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.login-card .login-logo p { color: var(--text-muted); font-size: 14px; }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-panel { margin-left: 0; }
    .top-header { left: 0; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .content-wrapper { padding: 16px; padding-top: 80px; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .form-row { grid-template-columns: 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }

/* ===== UTILITIES ===== */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success-dark) !important; }
.text-warning { color: var(--warning-dark) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--text-dark) !important; }

.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }

.text-end { text-align: right !important; }
.text-center { text-align: center !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 12px !important; }
.mb-3 { margin-bottom: 18px !important; }
.mt-3 { margin-top: 18px !important; }

.d-flex { display: flex !important; }
.justify-between { justify-content: space-between !important; }
.align-center { align-items: center !important; }
.gap-2 { gap: 12px !important; }
.gap-3 { gap: 18px !important; }

.w-100 { width: 100% !important; }
