/* ===== GLOBAL ===== */
/* ===== RESET & BOX-SIZING ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Ensure inputs never exceed their container */
input, select, textarea, button {
    max-width: 95%;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #eef6fb, #f8fbfe);
    margin: 0;
    padding: 0;
    color: #2c3e50;
    /* Mobile: prevent zoom on input focus (improves typing speed) */
    -webkit-text-size-adjust: 100%;
}

/* ===== CARD ===== */
.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(0, 102, 153, 0.08);
    border: 1px solid #e3eef7;
}

/* ===== HEADINGS ===== */
h2, h3 {
    margin-top: 0;
    color: #1f4e79;
}

/* ===== FORM ===== */
form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

/* Full width fields */
.full {
    grid-column: 1 / -1;
}

/* ===== LABELS ===== */
label {
    font-size: 13px;
    font-weight: 600;
    color: #4a6f8a;
    margin-bottom: 4px;
    display: block;
}

/* ===== INPUTS ===== */
input, select {
    width: 95%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d6e6f2;
    background: #f9fcff;
    transition: all 0.2s ease;
    font-size: 14px;
}

/* Focus effect */
input:focus, select:focus {
    outline: none;
    border-color: #4da3ff;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.15);
}

/* ===== BUTTON ===== */
button {
    background: linear-gradient(135deg, #4da3ff, #2b7cd3);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

/* Hover */
button:hover {
    background: linear-gradient(135deg, #3a8de0, #1f6bb8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(43, 124, 211, 0.3);
}

/* ===== TABLE ===== */
table.dataTable {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e3eef7;
}

/* Header */
table.dataTable thead {
    background: #eaf4fb;
    color: #1f4e79;
}

/* Rows */
table.dataTable tbody tr:hover {
    background: #f1f8ff;
}

/* ===== LINKS ===== */
a {
    color: #2b7cd3;
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

/* ===== SELECT2 ===== */
.select2-container .select2-selection--single {
    height: 42px;
    border-radius: 8px;
    border: 1px solid #d6e6f2;
    background: #f9fcff;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 42px;
    padding-left: 10px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

/* Dropdown */
.select2-dropdown {
    border-radius: 8px;
    border: 1px solid #d6e6f2;
}

/* ===== SMALL UTILITIES ===== */
.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

/* ===== TOP NAV (CLEAN FIXED) ===== */
.topnav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #2f80ed;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    z-index: 999;
}

/* Centered container */
.nav-container {
    max-width: 1100px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
}

/* Logo */
.logo {
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
}

/* Menu */
.nav-links {
    list-style: none;
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
}

/* Links */
.nav-links li {
    display: flex;
    align-items: center;
}

.nav-links li a {
    color: #eaf2ff;
    text-decoration: none;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.15s ease;
}

/* Hover */
.nav-links li a:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Active */
.nav-links li a.active {
    background: #ffffff;
    color: #2f80ed;
    font-weight: 600;
}

/* Content spacing */
.content {
    margin-top: 60px;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

/* ===== BASE MOBILE OVERRIDES (max-width: 768px) ===== */
@media (max-width: 768px) {
    .nav-links {
        flex-wrap: wrap;
        gap: 5px;
    }

    .nav-links li a {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* ===== ENHANCED MOBILE OPTIMIZATIONS FOR FAST TYPING ===== */
@media (max-width: 640px) {
    /* Reduce card padding for more screen space */
    .card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 16px;
    }

    /* Stack form fields vertically for easier tapping */
    form {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* Make all form controls larger (min 44px touch target) */
    input, select, button, .select2-container .select2-selection--single {
        min-height: 48px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    input, select, textarea, button {
        width: 95%;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }

    input, select {
        padding: 12px 14px;
        width: 95%;   /* your working solution */
        margin: 0 auto;
        display: block;
    }

    /* Increase label size & spacing */
    label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    /* Primary action button: full width + bigger tap area */
    button {
        width: 100%;
        padding: 14px;
        font-size: 16px;
        border-radius: 14px;
        margin-top: 8px;
    }

    /* Improve table readability on mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -4px;
        padding: 0 4px;
    }

    table.dataTable {
        min-width: 600px; /* Ensures horizontal scroll instead of squishing */
        font-size: 14px;
    }

    table.dataTable td, 
    table.dataTable th {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* Adjust spacing for quick-entry forms */
    .full {
        margin-bottom: 4px;
    }

    /* Sticky save/delete buttons for forms (if needed) */
    .sticky-actions {
        position: sticky;
        bottom: 12px;
        background: transparent;
        padding-top: 8px;
        margin-top: 8px;
        z-index: 10;
    }

    /* Better select2 mobile experience */
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 48px;
        font-size: 16px;
    }

    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 46px;
    }

    /* Increase spacing between interactive elements */
    .mt-20 {
        margin-top: 24px;
    }
}

/* Extra small devices (portrait phones) */
@media (max-width: 480px) {
    .content {
        margin-top: 56px;
        padding: 0 12px;
    }

    .nav-container {
        padding: 8px 12px;
    }

    .logo {
        font-size: 15px;
    }

    .nav-links li a {
        padding: 5px 8px;
        font-size: 11px;
    }

    /* Compact but still touch-friendly */
    .card {
        padding: 14px;
    }

    input, select, button {
        min-height: 44px;
    }

    /* Make amount input stand out */
    input[type="number"] {
        font-size: 18px;
        font-weight: 500;
    }

    /* Reduce modal/select2 padding if needed */
    .select2-dropdown {
        font-size: 15px;
    }
}

/* Optional: Improve numeric input for speed (requires html5 inputmode, but CSS can style) */
input[type="number"] {
    -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.5;
    height: 32px;
}

/* For quick add forms: group expense/income type as inline chips? Not possible with pure CSS, but increase select area */
select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%234a6f8a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
    padding-right: 36px;
}



/* ===== MENU HAMBURGUESA ===== */
.menu-toggle {
    display: none;          /* Oculto en desktop */
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    transition: opacity 0.2s;
}

.menu-toggle:hover {
    background: none;
    transform: none;
    box-shadow: none;
    opacity: 0.8;
}

/* Mobile: mostrar botón y colapsar menú */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;     /* Visible en móvil */
    }

    .nav-links {
        display: none;                     /* Oculto por defecto */
        flex-direction: column;
        width: 100%;
        background: #2f80ed;
        position: absolute;
        top: 100%;
        left: 0;
        padding: 12px 0;
        gap: 8px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.1);
        border-radius: 0 0 12px 12px;
        z-index: 1000;
    }

    .nav-links.active {
        display: flex;      /* Mostrar cuando se activa */
    }

    .nav-links li {
        width: 100%;
        text-align: center;
    }

    .nav-links li a {
        display: block;
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 0;
    }

    /* Ajuste para que el contenedor de navegación permita posicionar el menú desplegable */
    .topnav {
        position: relative; /* Para que el menú absoluto se posicione respecto al nav */
    }

    .nav-container {
        position: relative;
        flex-wrap: wrap;
    }
}