/* ========================================
   KuboPOS - Estilos Globales
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colores principales */
    --primary: #39ff88;
    --primary-dark: #1fdc6a;
    --primary-light: #6dffb1;
    --secondary: #4b5b78;
    --success: #39ff88;
    --warning: #fbbf24;
    --danger: #ff5f5f;
    --info: #38bdf8;
    
    /* Colores de fondo */
    --bg-dark: #0b1224;
    --bg-darker: #070d1c;
    --bg-light: #0a1220;
    --bg-white: #111c33;
    
    /* Colores de texto */
    --text-dark: #f8fafc;
    --text-light: #ffffff;
    --text-muted: #a3b2cc;
    
    /* Bordes */
    --border-color: #1f2a44;
    --border-dark: #2b3a5c;
    
    /* Sombras */
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 35px rgba(0, 0, 0, 0.4);
    
    /* Dimensiones */
    --sidebar-width: 250px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    
    /* Transiciones */
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* ========================================
   Scrollbars Personalizadas
   ======================================== */

/* Para navegadores Webkit (Chrome, Edge, Safari) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 10px;
    border: 2px solid var(--bg-darker);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

::-webkit-scrollbar-thumb:active {
    background: var(--primary-dark);
}

/* Para Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) var(--bg-darker);
}

#app {
    display: flex;
    min-height: 100vh;
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-darker);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
}

.version {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 10px;
}

.nav-menu {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

/* Scrollbar personalizado del menú */
.nav-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(57, 255, 136, 0.6) rgba(255, 255, 255, 0.04);
}

.nav-menu::-webkit-scrollbar {
    width: 10px;
}

.nav-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    margin: 6px 0;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(57, 255, 136, 0.95), rgba(57, 255, 136, 0.4));
    border-radius: 12px;
    border: 2px solid rgba(16, 24, 48, 0.6);
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(109, 255, 177, 0.95), rgba(57, 255, 136, 0.6));
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-dark);
    color: var(--text-light);
}

.nav-item.active {
    background: var(--bg-dark);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

.nav-icon {
    font-size: 1.25rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.nav-text {
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-dark);
}

.user-info {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
    transition: var(--transition);
    position: relative;
}

#module-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   Modal
   ======================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-white);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* ========================================
   Auth Container
   ======================================== */

.auth-container {
    text-align: center;
}

.auth-container h2 {
    margin-bottom: 25px;
    color: var(--text-light);
}

.auth-message {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--danger);
}

/* ========================================
   Forms
   ======================================== */

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-light);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-dark);
    color: var(--text-light);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(57, 255, 136, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #0b1224;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: #0b1224;
    font-weight: 600;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-light);
}

.btn-outline:hover {
    background: var(--bg-dark);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* ========================================
   Cards
   ======================================== */

.card {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-light);
}

/* ========================================
   Tables
   ======================================== */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-light);
}

th {
    background: var(--bg-dark);
    font-weight: 600;
    color: var(--text-light);
}

tr:hover {
    background: var(--bg-dark);
}

/* ========================================
   Module Header (shared across modules)
   ======================================== */

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.module-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-light);
    margin: 0;
}

/* ========================================
   Utilities
   ======================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    box-shadow: var(--shadow);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-light);
    z-index: 150;
}

/* ========================================
   Responsive
   ======================================== */

/* ========================================
   Notifications
   ======================================== */

.notification-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
    max-width: 360px;
}

.notification {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg-white);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border-color);
    transform: translateY(16px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    backdrop-filter: blur(6px);
    color: var(--text-light);
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    background: var(--bg-dark);
    color: var(--primary);
}

.notification-message {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-light);
    line-height: 1.35;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}

.notification-success {
    border-left: 4px solid var(--success);
}

.notification-success .notification-icon {
    background: rgba(57, 255, 136, 0.16);
    color: var(--success);
}

.notification-error {
    border-left: 4px solid var(--danger);
}

.notification-error .notification-icon {
    background: rgba(255, 95, 95, 0.18);
    color: var(--danger);
}

.notification-warning {
    border-left: 4px solid var(--warning);
}

.notification-warning .notification-icon {
    background: rgba(251, 191, 36, 0.18);
    color: var(--warning);
}

.notification-info {
    border-left: 4px solid var(--info);
}

.notification-info .notification-icon {
    background: rgba(56, 189, 248, 0.18);
    color: var(--info);
}

.sale-complete-toast {
    position: fixed;
    left: 50%;
    top: 16%;
    transform: translate(-50%, 0) scale(0.96);
    opacity: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 28px;
    border-radius: 16px;
    min-width: 520px;
    max-width: min(720px, 92vw);
    color: var(--text-light);
    background: linear-gradient(135deg, rgba(17, 28, 51, 0.95), rgba(11, 18, 36, 0.98));
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(57, 255, 136, 0.25);
    backdrop-filter: blur(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.sale-complete-toast.show {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
}

.sale-complete-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #0b1224;
    background: linear-gradient(135deg, #39ff88, #6dffb1);
    box-shadow: 0 10px 20px rgba(57, 255, 136, 0.3);
}

.sale-complete-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sale-complete-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.sale-complete-subtitle {
    font-size: 0.9rem;
    color: var(--primary-light);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .notification-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }

    .sale-complete-toast {
        width: calc(100% - 32px);
        min-width: auto;
        padding: 16px 18px;
        top: 12%;
    }
}

/* ========================================
   Pantalla de Login
   ======================================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top, rgba(57, 255, 136, 0.08), transparent 45%),
        linear-gradient(135deg, #0b1224 0%, #070d1c 55%, #0f1b33 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-screen.hidden {
    display: none;
}

.login-container {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    animation: loginSlideIn 0.4s ease;
}

@keyframes loginSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo {
    font-size: 64px;
    margin-bottom: 15px;
    animation: logoBounce 2s ease infinite;
}

@keyframes logoBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.login-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-light);
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 24px;
}

.login-form .form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.login-form .form-group input {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
    background: var(--bg-dark);
    color: var(--text-light);
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 4px rgba(57, 255, 136, 0.18);
}

.login-form .form-group input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    background: linear-gradient(135deg, #39ff88 0%, #1fdc6a 100%);
    border: none;
    color: #0b1224;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-login:hover {
    background: linear-gradient(135deg, #6dffb1 0%, #39ff88 100%);
    box-shadow: 0 8px 25px rgba(57, 255, 136, 0.4);
    transform: translateY(-2px);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-message {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
    display: none;
}

.login-message.error {
    display: block;
    background: rgba(255, 95, 95, 0.12);
    color: #ffb4b4;
    border: 1px solid rgba(255, 95, 95, 0.3);
}

.login-message.success {
    display: block;
    background: rgba(57, 255, 136, 0.12);
    color: #9cffc7;
    border: 1px solid rgba(57, 255, 136, 0.3);
}

.login-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0;
}

/* Ocultar app cuando no está logueado */
#app.hidden {
    display: none;
}

/* ========================================
   Global Loading Overlay
   ======================================== */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 13, 28, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.global-loader.active {
    display: flex;
    opacity: 1;
}

.loader-content {
    text-align: center;
    animation: fadeInUp 0.4s ease;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(57, 255, 136, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
