:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-input: #2d2d2d;
    --primary: #3498db;
    --primary-hover: #2980b9;
    --accent: #2ecc71;
    --danger: #e74c3c;
    --text-main: #e0e0e0;
    --text-muted: #b0b0b0;
    --border: #333;
    --sidebar-width: 260px;
    --header-height: 60px;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Responsive */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.sidebar-header .logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 1px;
}

.mobile-toggle {
    display: none;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.menu-item:hover,
.menu-item.active {
    color: var(--text-main);
    background-color: rgba(52, 152, 219, 0.1);
    border-left-color: var(--primary);
}

.menu-item i {
    width: 24px;
    margin-right: 10px;
    font-size: 18px;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s ease;
}

.top-bar {
    height: var(--header-height);
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.page-wrapper {
    padding: 30px;
    width: 100%;
}

.page-title {
    font-size: 24px;
    margin-bottom: 25px;
    font-weight: 600;
}

/* Cards & Panels */
.card {
    background-color: var(--bg-panel);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    width: 100%;
}

#pdf-title {
    font-size: 16px;
    word-break: break-all;
    flex: 1;
    margin-right: 15px;
    line-height: 1.2;
}

.card-title {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Forms Flexible */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: var(--border-radius);
    outline: none;
    transition: border-color 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--accent);
    color: white;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Grid System Responsive */
.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Tablas Responsivas */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    min-width: 600px;
    /* Asegura legibilidad en scroll */
}

th {
    text-align: left;
    padding: 15px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-autorizado {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.status-pendiente {
    background: rgba(241, 196, 15, 0.2);
    color: #f1c40f;
}

.status-error {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

/* Modales Responsivos */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    overflow-y: auto;
    padding: 10px;
}

.modal-content {
    background: var(--bg-panel);
    margin: 5% auto;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 600px;
    width: 95%;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* MEDIA QUERIES PARA RESPONSIVE TOTAL */

/* Tablets y Laptops Pequeñas */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }

    .page-wrapper {
        padding: 20px;
    }

    .row {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

/* Notificaciones Toast Premium */
.toast {
    min-width: 300px;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideIn 0.3s ease forwards;
    border-left: 5px solid var(--primary);
    backdrop-filter: blur(10px);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.success {
    border-left-color: var(--accent);
}

/* Changed from var(--success) to var(--accent) to match common variable usage */
.toast.warning {
    border-left-color: #f39c12;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Móviles (Pantallas pequeñas) */
@media (max-width: 768px) {
    .sidebar {
        left: -100%;
        width: 280px;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .mobile-toggle {
        display: flex !important;
    }

    .top-bar {
        padding: 0 15px;
    }

    .breadcrumb {
        display: none;
        /* Ocultamos breadcrumb en móvil para ganar espacio */
    }

    .page-wrapper {
        padding: 15px;
    }

    .row {
        grid-template-columns: 1fr;
        /* Una columna en móvil */
    }

    .card {
        padding: 15px;
    }

    .btn {
        width: 100%;
        margin-bottom: 5px;
    }

    /* Ajuste para formularios densos (Factura) */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* Micro Ajustes */
@media (max-width: 480px) {
    .page-title {
        font-size: 20px;
    }

    .modal-content {
        padding: 15px;
        margin: 2% auto;
    }
}