:root {
    --accent: #6b7280;
    --accent-glow: rgba(107, 114, 128, 0.2);
    --bg-main: #f3f4f6;
    --bg-card: rgba(255, 255, 255, 0.95);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-main: #374151;
    --text-muted: #6b7280;
}

body {
    background-color: var(--bg-main) !important;
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ========== GLASS CARD ========== */
.glass-card {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass) !important;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

/* ========== NAVBAR ========== */
.navbar-thehka {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    padding: 10px 20px;
}

.navbar-thehka .navbar-brand {
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: -0.5px;
    color: var(--text-main) !important;
}

.navbar-thehka .navbar-brand .accent {
    color: var(--accent);
}

.navbar-thehka .badge-bcv {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75em;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.navbar-thehka .badge-bcv:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-main);
}

/* ========== TABS ========== */
/* Paneles de pestañas: solo se muestra el que tiene la clase .active.
   (index.php además controla la visibilidad con style.display inline, que
   prevalece sobre esta regla, por lo que sigue funcionando igual.) */
.tab-pane-custom { display: none; }
.tab-pane-custom.active { display: block; }

.nav-tabs-custom {
    border-bottom: 2px solid var(--border-glass) !important;
    gap: 4px;
}

.nav-tabs-custom .nav-link {
    color: var(--text-muted) !important;
    border: none !important;
    border-radius: 8px 8px 0 0 !important;
    padding: 10px 20px;
    font-size: 0.95em;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-main) !important;
    background: rgba(0, 0, 0, 0.03);
}

.nav-tabs-custom .nav-link.active {
    color: var(--text-main) !important;
    background: rgba(0, 0, 0, 0.04) !important;
    border-bottom: 2px solid var(--accent) !important;
}

/* ========== FORMS ========== */
.form-control, .form-select {
    background-color: #ffffff !important;
    border-color: #848a96 !important;
    color: var(--text-main) !important;
    border-radius: 8px;
    padding: 10px 14px;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.form-control:hover, .form-select:hover {
    border-color: var(--text-muted) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 14px rgba(0, 0, 0, 0.12) !important;
}

.form-control::placeholder {
    color: #adb5bd;
}

.form-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

/* ========== BUTTONS ========== */
.btn-thehka {
    background: linear-gradient(135deg, #acb900, #8a9a20);
    color: #000;
    border: none;
    font-weight: 500;
    border-radius: 8px;
    padding: 10px 20px;
    transition: all 0.2s;
}

.btn-thehka:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(172, 185, 48, 0.25);
    color: #000;
}

.btn-glass {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-main);
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-glass:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #000;
}

.btn-sm-icon {
    padding: 5px 10px;
    font-size: 0.85em;
    border-radius: 6px;
}

/* ========== TABLES ========== */
.table-thehka {
    color: var(--text-main);
    margin-bottom: 0;
}

.table-thehka thead th {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-glass);
    padding: 12px 10px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-thehka tbody td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-thehka tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.table-wrapper {
    overflow-x: auto;
}

/* ========== BADGES ========== */
.badge-pending {
    background: #9ca3af !important;
    color: #1f2937 !important;
}

.badge-invoiced {
    background: #6b7280 !important;
    color: #fff !important;
}

.badge-anulada {
    background: #d1d5db !important;
    color: #374151 !important;
}

/* ========== ITEMS TABLE (index.php) ========== */
.items-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.items-table th {
    text-align: left;
    padding: 10px 8px;
    color: #666;
    font-size: 0.8em;
    background: rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
}

.items-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.items-table input,
.items-table select {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #8d939e;
    background: #fff;
    color: var(--text-main);
    font-size: 0.9em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.items-table input:hover,
.items-table select:hover {
    border-color: var(--text-muted);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.items-table input:focus,
.items-table select:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.items-section {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
}

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

.items-header h3 {
    margin: 0;
    font-size: 1em;
    color: var(--text-main);
}

.items-table-wrapper {
    overflow-y: auto;
    overflow-x: auto;
    max-height: 300px;
}

.btn-remove {
    background: #e74c3c;
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-remove:hover {
    background: #c0392b;
}

/* ========== TOTALES BOX ========== */
.totales-box {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.total-item {
    text-align: center;
    min-width: 100px;
}

.total-label {
    font-size: 0.75em;
    color: #888;
    margin-bottom: 3px;
}

.total-value {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--text-main);
}

.total-value.grand {
    font-size: 1.3em;
    color: #111827;
}

/* ========== AUTOCOMPLETE ========== */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-top: none;
    z-index: 1050;
    max-height: 250px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    display: none;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
}

.autocomplete-dropdown div {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: var(--text-main);
    font-size: 0.9em;
}

.autocomplete-dropdown div:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* ========== MODAL CUSTOM ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-glass {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px;
    padding: 25px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.1);
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.modal-glass .btn-close {
    filter: invert(0.4);
}

/* ========== IGTF BOX ========== */
.igtf-box {
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ========== TOAST ========== */
.toast-container-custom {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-custom {
    background: rgba(255, 255, 255, 0.98);
    border-left: 4px solid #9ca3af;
    color: var(--text-main);
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.3s ease forwards;
    backdrop-filter: blur(10px);
}

.toast-custom.success {
    border-color: #4b5563;
}

.toast-custom.error {
    border-color: #1f2937;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== BCV PAGE ========== */
.input-group-thehka {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid #848a96;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.input-group-thehka:hover {
    border-color: var(--text-muted);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.input-group-thehka:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 14px rgba(0, 0, 0, 0.12);
}

.input-group-thehka .input-group-text-thehka {
    background: rgba(0, 0, 0, 0.04);
    padding: 12px 15px;
    min-width: 150px;
    color: #555;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.9em;
}

.input-group-thehka input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 15px;
    color: var(--text-main);
    outline: none;
    font-size: 1rem;
}

.input-group-thehka input:focus {
    background: rgba(0, 0, 0, 0.02);
}

.api-panel {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.03) 0%, rgba(0, 0, 0, 0.05) 100%);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    display: none;
}

.api-panel h3 {
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.api-data {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

.api-data strong {
    color: var(--text-muted);
}

/* ========== ACTIONS CELL ========== */
.actions-cell {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.actions-cell .btn {
    padding: 5px 8px;
    font-size: 0.8em;
    white-space: nowrap;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .navbar-thehka .navbar-brand {
        font-size: 1em;
    }

    .nav-tabs-custom .nav-link {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .nav-tabs-custom .nav-link .tab-text {
        display: none;
    }

    .totales-box {
        flex-direction: column;
    }

    .totales-box .total-item {
        width: 100%;
    }

    .items-table th,
    .items-table td {
        padding: 6px 4px;
        font-size: 0.8em;
    }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}
