:root {
    --bg-color: #0a0e14;
    --surface-color: #161b22;
    --accent-color: #ff6b4a; /* Naranja Premium */
    --success-color: #10b981;
    --error-color: #ff4d4d;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --glass-bg: rgba(22, 27, 34, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body.dark-mode, body {
    background-color: #0a0e14 !important;
    color: #f9fafb !important;
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    margin: 0;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #0a0e14 !important;
}

main {
    flex: 1;
    padding: 20px;
    padding-bottom: 110px;
    background-color: #0a0e14 !important;
}

/* Header & Glassmorphism */
.main-header {
    background: linear-gradient(135deg, #1e0f0b 0%, #0a0e14 100%);
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-overlay.compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.app-brand {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
}

.logo-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-color);
}

.logo-mini i { width: 24px; height: 24px; }

.total-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    padding: 8px 15px;
    border-radius: 40px;
    border: 1px solid var(--glass-border);
}

.total-pill span { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; }
.total-pill h2 { font-size: 1.1rem; font-weight: 700; color: var(--success-color); }

/* Product Grid in Form */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.product-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.product-item.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.qty-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.qty-btn {
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    padding: 10px 0;
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.qty-btn.active {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 5px;
}

.status-dot.online { background: var(--success-color); box-shadow: 0 0 10px var(--success-color); }
.status-dot.offline { background: var(--error-color); box-shadow: 0 0 10px var(--error-color); }
.status-dot.syncing { background: #EAB308; animation: pulse 1s infinite; }

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.logo i {
    color: var(--accent-color);
    width: 28px;
    height: 28px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent-color);
    font-weight: 400;
}

/* Product Config Page Styles */
.product-config-card {
    background: var(--surface-color);
    padding: 15px;
    border-radius: 20px;
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
}

.product-config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.product-config-card.default-active {
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 107, 74, 0.2);
    background: rgba(255, 107, 74, 0.05);
}

.default-check {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    width: 32px;
    height: 32px;
}

.default-check input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.default-check i {
    color: var(--text-secondary);
    transition: all 0.3s;
}

.default-check input:checked ~ i {
    color: #FFD700; /* Dorado estrella */
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
    transform: scale(1.2);
}

.product-config-card input {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 10px;
    border-radius: 10px;
    width: 100%;
}

.btn-help {
    background: rgba(255,107,74,0.1);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Navigation */
.main-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    background: #161b22 !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around !important;
    padding: 10px 5px calc(15px + var(--safe-area-bottom)) !important;
    border-top: 1px solid var(--glass-border) !important;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5) !important;
    z-index: 9999 !important;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.6rem; /* Ultra-compacto */
    font-weight: 500;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 0;
}

.nav-btn.active {
    color: var(--accent-color);
}

.nav-btn i {
    width: 20px;
    height: 20px;
}

/* Page Transitions */
.page {
    display: none;
    padding: 20px;
    animation: fadeIn 0.4s ease-out;
    padding-bottom: 100px; /* Space for nav */
}

.page.active {
    display: block;
}

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

/* Search & Controls */
.list-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 25px;
}

.search-bar {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    border: 1px solid var(--glass-border);
}

.filter-btns {
    display: flex;
    gap: 8px;
}

.filter-btns button {
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btns button.active {
    background: var(--accent-color);
    color: white;
}

.search-bar i {
    color: var(--text-secondary);
    width: 20px;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 100%;
    font-size: 1rem;
    outline: none;
}

/* List Items */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.client-card {
    background: var(--surface-color);
    padding: 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease;
    border: 1px solid var(--glass-border);
}

.client-card:active {
    transform: scale(0.98);
}

.client-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 48px;
    height: 48px;
    min-width: 48px; /* Asegura el ancho mínimo */
    flex-shrink: 0; /* Impide que se aplaste */
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.client-head h3 {
    font-size: 1rem;
    font-weight: 600;
}

.client-head p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.client-balance {
    text-align: right;
}

.balance-amount {
    font-weight: 700;
    display: block;
}

.balance-amount.overdue { color: var(--error-color); }
.balance-amount.paid { color: var(--success-color); }

.days-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

/* UI Elements */
.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 1rem;
    width: 100%;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-primary:active {
    filter: brightness(0.9);
}

.fab {
    position: fixed;
    left: 20px; /* Movido a la izquierda */
    bottom: 90px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    border: none;
    z-index: 900;
}

#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000; /* Negro total de fondo para bloquear todo lo de atrás */
    display: flex;
    flex-direction: column;
    z-index: 2000;
    overflow-y: hidden; /* Evitamos que el contenedor scrollee, que lo haga el cuerpo */
}

#modal-container.hidden {
    display: none;
    opacity: 0;
}

.modal {
    width: 100%;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    background: var(--accent-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.btn-back, .btn-edit {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header h2 { font-size: 1.1rem; flex: 1; margin-left: 10px; }

.client-detail-top {
    background: linear-gradient(180deg, var(--accent-color) 0%, rgba(255,107,74,0.1) 100%);
    padding: 30px 20px;
    display: flex;
    flex-direction: column; /* Cambiamos a columna para más orden */
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.avatar-large {
    width: 80px;
    height: 80px;
    background: #FFD2C8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FF6B4A;
}

.balance-header {
    flex: 1;
}

.balance-header p { 
    font-size: 0.8rem; 
    color: var(--text-secondary); 
    margin-bottom: 5px;
}

.balance-header .amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.action-circles {
    display: flex;
    justify-content: space-around;
    padding: 20px 10px;
    border-bottom: 8px solid rgba(255,255,255,0.05);
}

.action-circle-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

.circle-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none; /* Quitamos bordes */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
}

.action-circle-btn:active .circle-icon {
    transform: scale(0.9);
}

.action-circle-btn span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 4px;
}

/* Botones de acción elegantes */
.btn-whatsapp { background: #25D366; }
.btn-debt { background: var(--error-color); }
.btn-payment { background: var(--success-color); }

.transaction-section-title {
    background: rgba(255,255,255,0.05);
    padding: 8px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-secondary);
}

.unified-transaction-list {
    padding: 20px 15px 40px;
}

.trans-row {
    background: rgba(255,255,255,0.03); /* Un poco de brillo para destacar la tarjeta */
    margin-bottom: 12px;
    padding: 15px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.trans-info { flex: 1; }
.trans-info .date { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.trans-info .desc { font-weight: 600; font-size: 1rem; margin-top: 3px; }

.trans-amounts { text-align: right; }
.trans-amounts .main-amt { font-weight: 800; font-size: 1.1rem; }
.trans-amounts .sub-bal { font-size: 0.75rem; color: var(--text-secondary); }

.trans-delete {
    color: #ff4d4d;
    padding: 10px;
    background: rgba(255,75,75,0.1);
    border-radius: 12px;
}

.amt-debt { color: var(--text-primary); }
.amt-payment { color: #22c55e; }

#modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-group input, .form-group textarea {
    width: 100%;
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
}

#import-area {
    min-height: 200px;
    margin-bottom: 15px;
}

/* Sync Overlays */
.sync-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 20, 0.95);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.sync-overlay.hidden { display: none; }

.sync-card {
    text-align: center;
    padding: 40px 25px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    max-width: 320px;
    background: var(--surface-color);
}

.sync-card h3 { margin-bottom: 15px; font-size: 1.4rem; }
.sync-card p { color: var(--text-secondary); margin-bottom: 25px; font-size: 0.95rem; }

/* Detail Elements */
.transaction-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--glass-border);
}

.transaction-item p { font-size: 0.9rem; }
.transaction-item .date { font-size: 0.75rem; color: var(--text-secondary); }
.transaction-item .amt { font-weight: 600; }

.debt-card-detail {
    background: rgba(255,255,255,0.03);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 15px;
}

.quick-actions {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.btn-icon {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    background: var(--surface-color);
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 12px;
    color: var(--text-primary);
}

.import-item.suggested {
    background: rgba(255, 107, 74, 0.1) !important;
    border-left: 3px solid var(--accent-color) !important;
}

.import-item.error {
    background: rgba(255, 77, 77, 0.1) !important;
    border-left: 3px solid var(--error-color) !important;
}

.selector-item:hover {
    background: rgba(255,255,255,0.1) !important;
}

/* --- TOGGLE SWITCH PREMIUM --- */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255,255,255,0.1);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.status-dot.syncing {
    background: #fbbf24;
    box-shadow: 0 0 10px #fbbf24;
}

.status-dot.offline {
    background: #94a3b8;
    box-shadow: 0 0 10px #94a3b8;
}
