/* =====================================================
   NeoFinance Design System - Global Styles
   Variables, Normalización, Shell PWA, Glassmorphism
   ===================================================== */

/* --- GOOGLE FONTS IMPORT --- */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Rajdhani:wght@300;400;500;600;700&display=swap');

/* --- CSS VARIABLES (:root) --- */
:root {
    /* Backgrounds */
    --bg-primary: #0a0e27;
    --bg-secondary: #0d1233;
    --bg-card: rgba(15, 20, 45, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);

    /* Borders */
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);

    /* Accent Colors */
    --cyan: #00F0FF;
    --cyan-dim: rgba(0, 240, 255, 0.3);
    --cyan-glow: rgba(0, 240, 255, 0.5);
    --orange: #FF7B00;
    --orange-dim: rgba(255, 123, 0, 0.3);
    --green: #00FF88;
    --green-dim: rgba(0, 255, 136, 0.3);
    --red: #FF2E4D;
    --red-dim: rgba(255, 46, 77, 0.3);
    --purple: #A855F7;
    --purple-dim: rgba(168, 85, 247, 0.3);
    --yellow: #FFD700;
    --yellow-dim: rgba(255, 215, 0, 0.3);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-muted: #555555;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-cyan: 0 0 15px var(--cyan-dim);
    --shadow-glow-green: 0 0 15px var(--green-dim);
    --shadow-glow-red: 0 0 15px var(--red-dim);
    --shadow-glow-orange: 0 0 15px var(--orange-dim);

    /* Fonts */
    --font-display: 'Orbitron', monospace;
    --font-body: 'Rajdhani', sans-serif;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal-backdrop: 900;
    --z-modal: 1000;
    --z-toast: 1100;
}

/* --- NORMALIZACIÓN --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background animado sutil */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(0, 240, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(255, 123, 0, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --- PREVENCIÓN DE ZOOM EN MÓVILES --- */
input, select, textarea {
    font-size: 16px !important; /* Previene zoom automático en iOS */
    font-family: var(--font-body);
}

/* --- TIPOGRAFÍA --- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.monto-numero {
    font-family: var(--font-display);
    font-weight: 700;
}

/* --- SHELL PWA - LAYOUT PRINCIPAL --- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* --- HEADER / NAVBAR --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header__logo {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header__nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.app-header__nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-header__nav a:hover,
.app-header__nav a.active {
    color: var(--cyan);
    background: var(--bg-glass-hover);
}

/* --- CONTENIDO PRINCIPAL --- */
.app-main {
    flex: 1;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- BOTTOM NAV (Mobile) --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    background: rgba(10, 14, 39, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav__items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.bottom-nav__item i {
    font-size: 1.2rem;
}

.bottom-nav__item:hover,
.bottom-nav__item.active {
    color: var(--cyan);
}

.bottom-nav__item.active {
    background: rgba(0, 240, 255, 0.1);
}

/* --- GLASSMORPHISM CARDS --- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition-normal);
}

.glass-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow-cyan);
}

/* --- BOTONES --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, var(--cyan), var(--orange));
    color: #000;
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.3);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.5);
}

.btn--secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    border-color: var(--cyan);
    box-shadow: var(--shadow-glow-cyan);
}

.btn--success {
    background: linear-gradient(135deg, var(--green), #00cc6a);
    color: #000;
}

.btn--danger {
    background: linear-gradient(135deg, var(--red), #cc0033);
    color: #fff;
}

.btn--warning {
    background: linear-gradient(135deg, var(--orange), #cc6200);
    color: #000;
}

.btn--whatsapp {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
}

.btn--sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn--lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn--icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
}

/* --- FORMULARIOS --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    transition: var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--cyan-dim);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    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='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* --- MODAL GLOBAL --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: var(--z-modal-backdrop);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--cyan);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--red);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease forwards;
}

.toast--success { border-left: 4px solid var(--green); }
.toast--error { border-left: 4px solid var(--red); }
.toast--warning { border-left: 4px solid var(--orange); }
.toast--info { border-left: 4px solid var(--cyan); }

.toast__icon {
    font-size: 1.2rem;
}

.toast--success .toast__icon { color: var(--green); }
.toast--error .toast__icon { color: var(--red); }
.toast--warning .toast__icon { color: var(--orange); }
.toast--info .toast__icon { color: var(--cyan); }

.toast__message {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* --- BADGES --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge--pending {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.badge--overdue {
    background: var(--red-dim);
    color: var(--red);
}

.badge--paid {
    background: var(--green-dim);
    color: var(--green);
}

.badge--warning {
    background: var(--orange-dim);
    color: var(--orange);
}

/* --- UTILIDADES --- */
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-purple { color: var(--purple); }
.text-yellow { color: var(--yellow); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-bold { font-weight: 700; }
.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; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }

/* Grid responsive */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --- ANIMACIONES --- */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px var(--cyan-dim); }
    50% { box-shadow: 0 0 20px var(--cyan-glow); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* --- LOADING SPINNER --- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .app-header__nav {
        display: none;
    }

    .bottom-nav {
        display: block;
    }

    .app-main {
        padding: 16px;
        padding-bottom: 80px; /* Espacio para bottom nav */
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }

    .toast-container {
        top: auto;
        bottom: 80px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- SCROLLBAR PERSONALIZADO --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--cyan-dim);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--cyan);
}

/* --- FOTO DE PERFIL --- */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--border);
    background: var(--bg-glass);
}

.avatar--sm { width: 36px; height: 36px; }
.avatar--lg { width: 64px; height: 64px; }
.avatar--xl { width: 80px; height: 80px; }

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cyan-dim), var(--purple-dim));
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
}