/* ============================================================
   SISTEMA DE BÁSCULA - ESTILOS PRINCIPALES
   Diseño profesional industrial
   ============================================================ */

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3a53;
    --secondary: #27ae60;
    --secondary-light: #2ecc71;
    --accent: #e67e22;
    --accent-light: #f39c12;
    --danger: #c0392b;
    --danger-light: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --success: #27ae60;
    --dark: #2c3e50;
    --gray-900: #1a1a2e;
    --gray-800: #2d2d44;
    --gray-700: #404060;
    --gray-600: #6c6c8a;
    --gray-500: #8e8ea0;
    --gray-400: #b0b0c0;
    --gray-300: #d0d0dd;
    --gray-200: #e8e8f0;
    --gray-100: #f4f4f8;
    --white: #ffffff;
    --bg: #f0f2f5;
    --sidebar-width: 260px;
    --header-height: 60px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --transition: all 0.25s ease;
    --font-sans: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', monospace;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--dark);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

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

/* ============================================================
   LAYOUT
   ============================================================ */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--gray-900) 100%);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
}

.sidebar-brand {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.15);
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    background: var(--secondary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
}

.sidebar-brand h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-brand small {
    font-size: 10px;
    opacity: 0.7;
    display: block;
}

.sidebar-nav { padding: 12px 0; }

.nav-section {
    padding: 8px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.nav-item.active {
    background: rgba(255,255,255,0.12);
    color: var(--white);
    border-left-color: var(--secondary);
}

.nav-item i { font-size: 16px; width: 20px; text-align: center; }

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

/* Header */
.top-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow);
}

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

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.breadcrumb-custom {
    font-size: 12px;
    color: var(--gray-500);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--gray-100);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.page-content { padding: 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-100);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.stat-icon.blue { background: rgba(52,152,219,0.12); color: var(--info); }
.stat-icon.green { background: rgba(39,174,96,0.12); color: var(--success); }
.stat-icon.orange { background: rgba(243,156,18,0.12); color: var(--warning); }
.stat-icon.red { background: rgba(231,76,60,0.12); color: var(--danger-light); }
.stat-icon.purple { background: rgba(142,68,173,0.12); color: #8e44ad; }

.stat-info h4 { font-size: 24px; font-weight: 700; color: var(--dark); line-height: 1.2; }
.stat-info p { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ============================================================
   TABLES
   ============================================================ */

.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    background: var(--gray-100);
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
    vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(52,152,219,0.04); }

.data-table tbody tr.anulado { opacity: 0.5; text-decoration: line-through; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: var(--transition);
    background: var(--white);
    color: var(--dark);
}

.form-control:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.form-control::placeholder { color: var(--gray-400); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--secondary-light); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-light); }
.btn-warning { background: var(--warning); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }

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

/* ============================================================
   BADGES & STATUS
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: rgba(39,174,96,0.12); color: var(--success); }
.badge-danger { background: rgba(231,76,60,0.12); color: var(--danger-light); }
.badge-warning { background: rgba(243,156,18,0.12); color: var(--warning); }
.badge-info { background: rgba(52,152,219,0.12); color: var(--info); }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* ============================================================
   PESO DISPLAY (Indicador de báscula)
   ============================================================ */

.peso-display {
    background: linear-gradient(135deg, var(--gray-900), #1a2a3a);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    color: #00ff88;
    font-family: var(--font-mono);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), var(--shadow-lg);
    border: 2px solid #333;
    position: relative;
    overflow: hidden;
}

.peso-display::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.05) 2px,
        rgba(0,0,0,0.05) 4px
    );
    pointer-events: none;
}

.peso-value {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0,255,136,0.4);
    position: relative;
}

.peso-unit { font-size: 18px; opacity: 0.7; margin-left: 4px; }
.peso-status { font-size: 12px; margin-top: 8px; opacity: 0.6; }
.peso-status.estable { color: #00ff88; }
.peso-status.inestable { color: #ff6b6b; animation: blink 1s infinite; }

@keyframes blink { 50% { opacity: 0.3; } }

/* ============================================================
   TOOLBAR & FILTERS
   ============================================================ */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-box {
    position: relative;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1.5px solid var(--gray-300);
    border-radius: 20px;
    font-size: 13px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 14px;
}

.filter-panel {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: none;
    animation: slideDown 0.3s ease;
}

.filter-panel.show { display: block; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show { display: flex; }

@keyframes fadeIn { from { opacity: 0; } }

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn { from { transform: scale(0.95); } }

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-100);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px;
}

/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.pagination-info { font-size: 12px; color: var(--gray-500); margin: 0 12px; }

/* ============================================================
   TOAST / NOTIFICATIONS
   ============================================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}

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

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--gray-900));
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-card .brand-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: white;
}

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

.login-card p { color: var(--gray-500); font-size: 13px; margin-bottom: 24px; }

.login-card .form-control {
    padding: 12px 14px;
    font-size: 15px;
    margin-bottom: 12px;
}

.login-card .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .sidebar, .top-header, .toolbar, .btn-group, .pagination, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { font-size: 12px; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
    .form-row-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row, .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: unset; }
    .stat-card { padding: 14px; }
    .stat-info h4 { font-size: 20px; }
    .peso-value { font-size: 36px; }
    .modal-content { max-width: 100%; margin: 10px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger-light); }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; }
.gap-1 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none; }

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}
