@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&display=swap');

/* ==========================================================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ========================================================================== */
:root {
    --color-bg: #020617; /* Slate 950 */
    --color-glass: rgba(15, 23, 42, 0.7);
    --color-border: rgba(255, 255, 255, 0.08);
    --color-scrollbar-track: #0f172a;
    --color-scrollbar-thumb: #334155;
    --color-scrollbar-thumb-hover: #475569;
    --color-success: #22c55e;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(56, 189, 248, 0.08), transparent 25%), 
        radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.08), transparent 25%);
    margin: 0;
    min-height: 100vh;
}

/* ==========================================================================
   UTILIDADES DE SCROLLBAR
   ========================================================================== */
/* Scrollbar global */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--color-scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--color-scrollbar-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-scrollbar-thumb-hover);
}

/* Ocultar scrollbar pero mantener funcionalidad */
.hide-scrollbar::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.hide-scrollbar,
.no-scrollbar {
    -ms-overflow-style: none;  /* IE y Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Scrollbar personalizado para contenedores específicos */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #1f2937; 
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #4b5563; 
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #6b7280; 
}

/* ==========================================================================
   COMPONENTES ESPECÍFICOS
   ========================================================================== */

/* ----- TOAST NOTIFICATIONS ----- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
#toast-container.show {
    transform: translateY(0);
    opacity: 1;
}
.toast-content {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
    font-size: 13px;
    gap: 12px;
}
.toast-success { border-left: 4px solid var(--color-success); }
.toast-error { border-left: 4px solid var(--color-error); }

/* ----- GLASSMORPHISM ----- */
.glass-panel {
    background: var(--color-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
}
.glass-header {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ----- BOTONES Y PESTAÑAS ----- */
.tab-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.tab-btn.active {
    background-color: #ef4444; /* red-500 */
    color: white;
}
.active-tab-bg {
    background-color: #374151; /* gray-700 */
    color: white !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}
.price-nav-btn.active,
.otros-nav-btn.active,
.pin-tab.active {
    background-color: #4b5563; /* gray-600 */
    font-weight: 600;
}
.active-filter {
    background-color: #3b82f6 !important;
    color: white !important;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.5);
    border-color: #2563eb !important;
}

/* ----- FILAS DE TABLA Y DETALLES ----- */
.details-row {
    background-color: #1f2937;
}
.details-row td {
    padding: 0 !important;
}
.expand-btn {
    transition: transform 0.2s ease-in-out;
}
.expanded .expand-btn {
    transform: rotate(180deg);
}
th[data-sort-key] {
    cursor: pointer;
}
th[data-sort-key]:hover {
    color: white;
}

/* Efectos de guardado en filas */
.row-saved {
    background-color: rgba(34, 197, 94, 0.25) !important;
}
.row-just-saved {
    background-color: rgba(34, 197, 94, 0.2);
    transition: background-color 0.5s ease;
    animation: flash-effect 1.5s ease-in-out;
}
@keyframes flash-effect {
    0%   { background-color: transparent; }
    50%  { background-color: rgba(34, 197, 94, 0.25); }
    100% { background-color: transparent; }
}

/* Efecto de éxito en botón guardar */
.save-success-effect {
    animation: pulse-success 0.5s 1;
}
@keyframes pulse-success {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ----- CUENTAS PAUSADAS ----- */
.row-paused {
    opacity: 0.6;
    background-color: rgba(51, 65, 85, 0.3) !important;
    filter: grayscale(0.8);
    position: relative;
}
.row-paused::after {
    content: "⏸ PAUSADA";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-5deg);
    font-size: 2rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.1);
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
}
.badge-paused {
    background-color: #f59e0b;
    color: black;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ----- FORMULARIOS Y ENTRADAS ----- */
.details-input,
.custom-select,
.details-textarea {
    background-color: #374151; /* gray-700 */
    border: 1px solid #4b5563; /* gray-600 */
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    width: 100%;
}
.form-container {
    transition: background-color 0.3s ease;
}

/* Ocultar flechas en inputs number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

/* Autocompletado del navegador */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px #111827 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    border-radius: 0.5rem !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ----- AUTocompletado personalizado ----- */
.custom-autocomplete-list {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #1f2937;
}
.custom-autocomplete-list::-webkit-scrollbar {
    width: 8px;
}
.custom-autocomplete-list::-webkit-scrollbar-track {
    background: #1f2937;
    border-radius: 0 0 8px 0;
}
.custom-autocomplete-list::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}
.custom-autocomplete-list::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ----- SORTABLE (Drag & Drop) ----- */
.sortable-ghost {
    opacity: 0.4;
    background-color: #3f4e64;
    border: 1px dashed #6b7280;
}
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }

/* ----- ESTRELLAS (Favoritos) ----- */
.star-btn {
    cursor: pointer;
    color: #6b7280; /* gray-500 */
}
.star-btn.starred {
    color: #facc15; /* yellow-400 */
}

/* ----- PINES ----- */
.pin-used {
    text-decoration: line-through;
    color: #6b7280;
}

/* ==========================================================================
   MÓDULOS ESPECÍFICOS
   ========================================================================== */

/* ----- GESTIÓN DE COBROS (RENEWALS) ----- */
.dashboard-stat-card {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}
.renewal-card {
    background: #0f172a;
    border: 1px solid rgba(51, 65, 85, 0.5);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.renewal-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
    border-color: rgba(96, 165, 250, 0.3);
}
/* Bordes de estado para tarjetas de renovación */
.status-border-expired { border-left: 4px solid #ef4444; }
.status-border-urgent { border-left: 4px solid #f59e0b; }
.status-border-soon { border-left: 4px solid #3b82f6; }
.btn-whatsapp-action {
    background: linear-gradient(to right, #059669, #10b981);
    color: white;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-whatsapp-action:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

/* ----- BILLETERA (WALLET) ----- */
.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(51, 65, 85, 0.3);
    transition: all 0.2s;
}
.transaction-item:hover {
    background: rgba(30, 41, 59, 1);
    border-color: rgba(96, 165, 250, 0.3);
}
.amount-income { 
    color: #34d399; 
    font-weight: 700; 
    font-family: monospace; 
}
.amount-expense { 
    color: #f87171; 
    font-weight: 700; 
    font-family: monospace; 
}

/* ==========================================================================
   ANIMACIONES GLOBALES
   ========================================================================== */
.animate-slide-in {
    animation: slideIn 0.3s ease-out forwards;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}