/* =====================================================
   Sistema POS - Ventas Advisor
   Estilos principales
   ===================================================== */

:root {
    /* Paleta basada en Servicio Técnico */
    --mt-primary: #65717d;
    --mt-primary-hover: #56616d;
    --mt-secondary: #7b8794;
    --mt-secondary-hover: #6b7681;
    --mt-accent: #4f7ca8;
    --mt-success: #198754;
    --mt-warning: #ffc107;
    --mt-danger: #dc3545;
    --mt-info: #4f7ca8;
    --mt-light: #f8fafc;
    --mt-dark: #1f2933;
    --mt-gray: #6c757d;
    --mt-page-bg: #f8fafc;

    --bs-primary: #65717d;
    --bs-primary-rgb: 101, 113, 125;
}

/* ==================== ESTILOS GLOBALES ==================== */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--mt-page-bg);
    min-height: 100vh;
    padding-top: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.app-main {
    flex: 1;
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--mt-primary);
    box-shadow: 0 0 0 0.2rem rgba(101, 113, 125, 0.15);
}

.text-primary {
    color: var(--mt-primary-hover) !important;
}

.alert {
    border: none;
    border-radius: 10px;
}

.badge {
    font-weight: 500;
    border-radius: 6px;
}

/* ==================== NAVEGACIÓN ==================== */

.navbar {
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.2rem;
}

.navbar-brand img {
    max-width: 220px;
    object-fit: contain;
}

.bg-primary {
    background-color: var(--mt-primary) !important;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    transition: background-color 0.2s, color 0.2s;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link:focus {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.10);
}

.dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.dropdown-item {
    border-radius: 8px;
}

.dropdown-item:active {
    background-color: var(--mt-primary);
}

/* ==================== BOTONES ==================== */

.btn {
    border-radius: 8px;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, var(--mt-primary) 0%, var(--mt-primary-hover) 100%);
    border-color: var(--mt-primary);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--mt-primary-hover) 0%, #48525d 100%);
    border-color: var(--mt-primary-hover);
}

.btn-outline-primary {
    color: var(--mt-primary-hover);
    border-color: var(--mt-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary {
    background-color: var(--mt-primary);
    border-color: var(--mt-primary);
    color: #fff;
}

.btn-secondary {
    background-color: var(--mt-secondary);
    border-color: var(--mt-secondary);
}

.btn-secondary:hover {
    background-color: var(--mt-secondary-hover);
    border-color: var(--mt-secondary-hover);
}

.btn-success {
    background-color: var(--mt-success);
    border-color: var(--mt-success);
}

.btn-warning {
    background-color: var(--mt-warning);
    border-color: var(--mt-warning);
}

.btn-danger {
    background-color: var(--mt-danger);
    border-color: var(--mt-danger);
}

.btn-info {
    background-color: var(--mt-info);
    border-color: var(--mt-info);
}

/* ==================== TARJETAS ==================== */

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease-in-out;
}

.card:hover {
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    padding: 1rem 1.5rem;
}

.card-header.bg-primary {
    background-color: var(--mt-primary) !important;
    color: white !important;
    border-bottom: none;
}

.card-header.bg-primary h5,
.card-header.bg-primary h6 {
    color: white !important;
    margin-bottom: 0;
}

.card-header.bg-secondary {
    background-color: var(--mt-secondary) !important;
    color: white !important;
    border-bottom: none;
}

.card-header.bg-info {
    background-color: var(--mt-info) !important;
    color: white !important;
    border-bottom: none;
}

.card-header.bg-success {
    background-color: var(--mt-success) !important;
    color: white !important;
    border-bottom: none;
}

.card-body {
    padding: 1.5rem;
}

/* ==================== TARJETAS DE ESTADÍSTICAS ==================== */

.stats-card {
    background: linear-gradient(135deg, var(--mt-primary), var(--mt-primary-hover));
    color: white;
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(101, 113, 125, 0.24);
}

.stats-card.secondary {
    background: linear-gradient(135deg, var(--mt-secondary), var(--mt-secondary-hover));
    box-shadow: 0 4px 15px rgba(123, 135, 148, 0.24);
}

.stats-card.success {
    background: linear-gradient(135deg, var(--mt-success), #34ce57);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.stats-card.warning {
    background: linear-gradient(135deg, var(--mt-warning), #ffcd3c);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.stats-card.info {
    background: linear-gradient(135deg, var(--mt-info), #416b94);
    box-shadow: 0 4px 15px rgba(79, 124, 168, 0.24);
}

.stats-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.stats-card p {
    margin: 0;
    opacity: 0.9;
    font-size: 1rem;
}

.stats-card i {
    font-size: 3rem;
    opacity: 0.3;
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
}

/* ==================== TABLAS ==================== */

.table {
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.table thead th {
    background-color: var(--mt-primary);
    color: white;
    border: none;
    font-weight: 500;
    padding: 1rem;
    text-align: center;
    vertical-align: middle;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-top: 1px solid #eee;
    color: #333 !important;
}

.table tbody td code {
    color: #333 !important;
}

.table tbody tr:hover {
    background-color: rgba(52, 62, 97, 0.05);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ==================== BADGES Y ESTADOS ==================== */

.badge {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
}

.badge.status-pending {
    background-color: var(--mt-warning);
    color: #000;
}

.badge.status-approved {
    background-color: var(--mt-success);
    color: white;
}

.badge.status-rejected {
    background-color: var(--mt-danger);
    color: white;
}

.badge.status-completed {
    background-color: var(--mt-success);
    color: white;
}

.badge.status-cancelled {
    background-color: var(--mt-gray);
    color: white;
}

.badge.status-converted {
    background-color: var(--mt-info);
    color: white;
}

.badge.stock-ok {
    background-color: var(--mt-success);
    color: white;
}

.badge.stock-low {
    background-color: var(--mt-warning);
    color: #000;
}

.badge.stock-out {
    background-color: var(--mt-danger);
    color: white;
}

/* ==================== FORMULARIOS ==================== */

.form-control, .form-select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    padding: 0.75rem;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: var(--mt-primary);
    box-shadow: 0 0 0 0.2rem rgba(52, 62, 97, 0.25);
}

.form-label {
    font-weight: 500;
    color: var(--mt-dark);
    margin-bottom: 0.5rem;
}

.form-check-input:checked {
    background-color: var(--mt-primary);
    border-color: var(--mt-primary);
}

/* ==================== PÁGINA DE LOGIN ==================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e5e7eb 52%, #cbd5e1 100%);
    padding: 1rem;
}

.login-card {
    max-width: 430px;
    width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 2.25rem;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.14);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo img {
    display: block;
    max-width: min(260px, 100%);
    max-height: 72px;
    object-fit: contain;
    margin: 0 auto 1rem;
}

.login-logo h2 {
    color: #1f2937;
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.login-form .form-label {
    color: #374151;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
}

.login-form .form-control {
    height: 46px;
    border-radius: 6px;
    border-color: #cbd5e1;
    color: #1f2937;
    padding-left: 0.9rem;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover,
.password-toggle:focus {
    color: var(--mt-primary);
    background: #eef2f7;
    outline: none;
}

.login-submit {
    border-radius: 6px;
    font-weight: 600;
}

/* ==================== POS - PUNTO DE VENTA ==================== */

.pos-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    height: calc(100vh - 100px);
}

.products-section {
    overflow-y: auto;
    padding-right: 1rem;
}

.cart-section {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.product-card {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #e9ecef;
}

.product-card:hover {
    border-color: var(--mt-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 62, 97, 0.2);
}

.product-card.selected {
    border-color: var(--mt-primary);
    background-color: rgba(52, 62, 97, 0.05);
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-total {
    background: var(--mt-light);
    padding: 1rem;
    border-radius: 8px;
    margin-top: auto;
}

/* ==================== SCANNER QR ==================== */

.qr-scanner-container {
    max-width: 600px;
    margin: 0 auto;
}

#qr-reader {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.qr-result {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ==================== ETIQUETAS QR ==================== */

.qr-label {
    background: white;
    border: 2px dashed var(--mt-gray);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.qr-label img {
    max-width: 200px;
    margin: 1rem auto;
}

/* ==================== BÚSQUEDA ==================== */

.search-box {
    position: relative;
}

.search-box .form-control {
    padding-left: 2.5rem;
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--mt-gray);
}

/* ==================== ANIMACIONES ==================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ==================== SPINNER ==================== */

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner-border-custom {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
    border-color: var(--mt-primary);
    border-right-color: transparent;
}

/* ==================== UTILIDADES ==================== */

.text-primary-custom {
    color: var(--mt-primary) !important;
}

.bg-primary-custom {
    background-color: var(--mt-primary) !important;
}

.border-primary-custom {
    border-color: var(--mt-primary) !important;
}

.hover-shadow:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

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

@media (max-width: 1200px) {
    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .cart-section {
        margin-top: 2rem;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }

    .stats-card h3 {
        font-size: 2rem;
    }

    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .table-responsive {
        border-radius: 10px;
    }

    .login-card {
        padding: 2rem;
    }

    .card-body {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .stats-card h3 {
        font-size: 1.5rem;
    }

    .stats-card {
        padding: 1rem;
    }
}

/* ==================== IMPRESIÓN ==================== */

@media print {
    .navbar, .btn, .card-header .btn-group, .no-print {
        display: none !important;
    }

    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    body {
        padding-top: 0;
    }

    .container-fluid {
        padding: 0;
    }

    @page {
        margin: 1cm;
    }
}

/* ==================== SCROLL ==================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--mt-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mt-primary-hover);
}
