/* ==========================================================================
   AIRBRUSH HelpDesk IT - Modern Theme
   Mejoras visuales globales: glassmorphism, animaciones, tipografía, UI.
   ========================================================================== */

/* ---- Variables ---- */
:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --bg-dark: #0a192f;
    --bg-dark-2: #112240;
    --primary: #0b2a5e;
    --primary-light: #1e5bc2;
    --accent: #e30613;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* ---- Tipografía base ---- */
body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-dark-2) 100%);
    color: var(--text-main);
    overflow-x: hidden;
}

/* ---- Fondo dinámico con orbes ---- */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.45;
    z-index: 0;
    pointer-events: none;
}

body::before {
    width: 500px;
    height: 500px;
    background: #1e5bc2;
    top: -120px;
    left: -120px;
    animation: orbMove1 20s ease-in-out infinite alternate;
}

body::after {
    width: 400px;
    height: 400px;
    background: #e30613;
    bottom: -80px;
    right: -80px;
    animation: orbMove2 24s ease-in-out infinite alternate;
}

@keyframes orbMove1 {
    from { transform: translate(0, 0); }
    to { transform: translate(60px, 80px); }
}

@keyframes orbMove2 {
    from { transform: translate(0, 0); }
    to { transform: translate(-60px, -60px); }
}

.overlay {
    background: rgba(10, 25, 47, 0.78);
    backdrop-filter: blur(4px);
}

/* ---- Iconografía Lucide ---- */
i[data-lucide] {
    width: 24px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
}

/* ---- Topbar moderno ---- */
.top-bar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-sm);
}

.top-bar .nav-links a,
.top-bar .nav-links button {
    transition: color var(--transition-fast);
}

.top-bar .nav-links a:hover,
.top-bar .nav-links button:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ---- Glass card mejorado ---- */
.glass-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.glass-card:hover {
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(30, 91, 194, 0.08);
    border-color: rgba(30, 91, 194, 0.35);
}

/* ---- Animaciones globales ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulseBadge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(227, 6, 19, 0.25); }
    50% { box-shadow: 0 0 0 6px rgba(227, 6, 19, 0); }
}

@keyframes iconSpring {
    0% { transform: scale(1) rotate(0deg); }
    40% { transform: scale(1.2) rotate(-8deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes focusGlow {
    from { box-shadow: 0 0 0 0 rgba(30, 91, 194, 0.25); }
    to { box-shadow: 0 0 0 4px rgba(30, 91, 194, 0.12); }
}

.glass-card {
    animation: fadeInUp 0.55s ease both;
}

/* ---- Botones modernos ---- */
.portal-btn,
.glass-card .portal-btn,
.portal-form button[type="submit"] {
    border-radius: var(--radius);
    background: var(--primary);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast),
                box-shadow var(--transition-fast),
                background var(--transition-fast);
}

.portal-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 25%, rgba(255,255,255,0.25) 50%, transparent 75%);
    background-size: 200% 100%;
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.portal-btn:hover::after {
    transform: translateX(100%);
    transition: transform 0.7s;
}

.portal-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--accent);
}

.portal-form .btn-create {
    background: var(--accent);
    border-radius: 10px;
    width: 100%;
    margin-top: 8px;
}

.portal-form .btn-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(227, 6, 19, 0.25);
    background: #c00510;
}

.portal-btn:active,
.portal-form button[type="submit"]:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: none;
}

/* ---- KPI cards pastel ---- */
.kpi-grid {
    gap: 18px;
}

.kpi-card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.kpi-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.kpi-total .kpi-icon { background: #eff6ff; color: #2563eb; }
.kpi-abiertos .kpi-icon { background: #fee2e2; color: #dc2626; }
.kpi-proceso .kpi-icon { background: #dbeafe; color: #2563eb; }
.kpi-cerrados .kpi-icon { background: #d1fae5; color: #16a34a; }
.kpi-anulados .kpi-icon { background: #f1f5f9; color: #64748b; }

/* ---- Badges de estado ---- */
.badge {
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

.badge-abierto {
    background: #e30613;
    color: #fff;
    animation: pulseBadge 2s infinite;
}

.badge-proceso { background: #1e5bc2; color: #fff; }
.badge-cerrado { background: #16a34a; color: #fff; }
.badge-anulado { background: #6c757d; color: #fff; }

/* ---- Badges de prioridad ---- */
.portal-table .priority-p1,
.portal-table .priority-p2,
.portal-table .priority-p3,
.portal-table .priority-p4 {
    color: #fff !important;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

.portal-table .priority-p1 { background: #dc2626; }
.portal-table .priority-p2 { background: #ea580c; }
.portal-table .priority-p3 { background: #2563eb; }
.portal-table .priority-p4 { background: #16a34a; }

/* ---- Tabla moderna ---- */
.portal-table {
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 16px;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
}

.portal-table thead tr {
    background: #0a192f;
}

.portal-table th {
    background: transparent !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: none;
    padding: 14px 16px;
    text-align: center;
}

.portal-table tbody tr:nth-child(even) {
    background: #f1f5f9;
}

.portal-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.portal-table td {
    color: var(--text-main);
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 16px;
    font-size: 13px;
    text-align: center;
}

.portal-table tbody tr {
    transition: background var(--transition-fast);
}

.portal-table tbody tr:hover {
    background: #dbeafe;
}

/* ---- Acciones y botones de tabla (.btn-sm) ---- */
.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.actions-cell {
    white-space: nowrap;
}

.btn-sm,
a.btn-sm,
button.btn-sm,
input[type="submit"].btn-sm {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 78px !important;
    min-width: 78px !important;
    max-width: 78px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 999px !important;
    border: none !important;
    outline: none !important;
    font-family: var(--font-main) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-align: center !important;
    text-decoration: none !important;
    color: #ffffff !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    background: var(--primary) !important;
    box-shadow: 0 2px 6px rgba(11, 42, 94, 0.2);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    vertical-align: middle;
}

.btn-sm:hover,
a.btn-sm:hover,
button.btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(11, 42, 94, 0.35);
    background: #1e5bc2 !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

.btn-sm:active,
a.btn-sm:active,
button.btn-sm:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(11, 42, 94, 0.2);
}

.btn-sm-danger,
a.btn-sm-danger,
button.btn-sm-danger {
    background: var(--accent) !important;
    box-shadow: 0 2px 6px rgba(227, 6, 19, 0.25);
}

.btn-sm-danger:hover,
a.btn-sm-danger:hover,
button.btn-sm-danger:hover {
    background: #b0050f !important;
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.4) !important;
}

/* ---- Formularios modernos ---- */
.portal-form input,
.portal-form select,
.portal-form textarea,
.modal-select,
.modal-textarea {
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast),
                background var(--transition-fast);
}

.portal-form textarea {
    resize: none;
}

.portal-form select:disabled,
.modal-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
}

.portal-form input:focus,
.portal-form select:focus,
.portal-form textarea:focus,
.modal-select:focus,
.modal-textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(30, 91, 194, 0.12);
    background: #fff;
    animation: focusGlow 0.25s ease forwards;
}

/* ---- Formulario de búsqueda ---- */
.search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-form .search-input {
    flex: 1 1 260px;
    min-width: 200px;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid #cbd5e1;
    background: #fff;
    font-family: var(--font-main);
    font-size: 14px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-form .search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(30, 91, 194, 0.12);
}

/* ---- Lista de archivos adjuntos ---- */
.file-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-main);
}

.file-item .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .file-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: #fee2e2;
    color: #b91c1c;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.file-item .file-remove:hover {
    background: #fecaca;
    transform: scale(1.05);
}

.file-item .file-remove svg {
    width: 16px;
    height: 16px;
}

/* ---- Pasos progresivos del formulario ---- */
.form-step {
    max-height: 0;
    opacity: 0;
    transform: translateY(12px);
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.35s ease, transform 0.35s ease, margin 0.35s ease;
    margin-bottom: 0;
}

.form-step.visible {
    max-height: 400px;
    opacity: 1;
    transform: translateY(0);
    margin-bottom: 16px;
}

.form-step.visible:last-child {
    margin-bottom: 0;
}

/* ---- Dropzone para archivos ---- */
.file-dropzone {
    width: 100%;
    padding: 32px 24px;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color var(--transition-fast),
                border-style var(--transition-fast),
                background var(--transition-fast),
                transform var(--transition-fast);
}

.file-dropzone:hover {
    border-color: var(--primary-light);
    background: #eff6ff;
    transform: translateY(-2px);
}

.file-dropzone.dragover {
    border: 2px solid var(--accent);
    background: #fff1f2;
    transform: scale(1.01);
}

.file-dropzone.dragover .dropzone-icon {
    transform: translateY(-4px);
}

.file-dropzone .dropzone-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--primary-light);
    transition: transform var(--transition-fast);
}

.file-dropzone .dropzone-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.file-dropzone .dropzone-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.file-dropzone input[type="file"] {
    display: none;
}

/* ---- Home cards ---- */
.home-title {
    font-weight: 800;
    letter-spacing: -0.5px;
}

.home-subtitle {
    color: rgba(255, 255, 255, 0.8);
}

.portal-card {
    position: relative;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
    overflow: hidden;
    transition: transform var(--transition-normal),
                box-shadow var(--transition-normal);
}

.portal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-normal);
}

.portal-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(226, 232, 240, 0.8);
}

.portal-card:hover::before {
    transform: scaleX(1);
}

.portal-card .icon {
    color: var(--primary);
    transition: transform var(--transition-normal);
}

.portal-card:hover .icon {
    transform: scale(1.15) rotate(-5deg);
}

.portal-card h3 {
    color: var(--text-main);
    font-weight: 700;
}

.portal-card p {
    color: var(--text-muted);
}

.portal-card .link-text {
    color: var(--primary);
    font-weight: 600;
}

/* ---- Celdas de acciones ---- */
.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn-sm {
    margin-right: 4px;
    margin-bottom: 2px;
}

.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background var(--transition-fast),
                color var(--transition-fast),
                transform var(--transition-fast);
}

.action-icon:hover {
    background: #eff6ff;
    color: var(--primary);
    transform: scale(1.1);
}

.action-icon.action-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.action-icon svg,
.action-icon i {
    width: 18px;
    height: 18px;
}

/* ---- Paginación ---- */
.pagination-wrapper a {
    border-radius: var(--radius);
    background: #0b2a5e;
    color: #fff !important;
    border: 1px solid #0b2a5e;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.pagination-wrapper a:hover {
    background: #e30613;
    border-color: #e30613;
    color: #fff !important;
}

.pagination-info {
    color: var(--text-main);
    font-weight: 600;
}

/* ---- Transición suave en tabla de usuarios ---- */
#usuarios-container {
    min-height: 260px;
}

.portal-table.table-fixed {
    table-layout: fixed;
}

.portal-table.table-fixed th,
.portal-table.table-fixed td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.portal-table.table-fixed tbody tr {
    animation: rowFadeIn 0.5s ease;
}

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

@media (max-width: 768px) {
    .portal-table.table-fixed {
        table-layout: auto;
        min-width: 760px;
    }
}

/* ---- Overlay de éxito al crear ticket (PedidosYa style) ---- */
.success-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 25, 47, 0.94);
    backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.success-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.success-overlay.active .success-badge {
    animation: badgePop 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.success-overlay.active .success-ripple {
    animation: badgeRipple 0.7s 0.35s ease-out forwards;
}

.success-overlay.active .success-check-path {
    animation: successCheckDraw 0.45s 0.45s ease forwards;
}

.success-overlay.active .success-text {
    animation: successTextFade 0.4s 0.55s ease forwards;
}

.success-badge {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0) rotate(-45deg);
}

.success-ripple {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(22, 163, 74, 0.35);
    transform: scale(0.8);
    opacity: 0;
}

.success-circle {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 40px rgba(22, 163, 74, 0.35);
}

.success-check {
    width: 52px;
    height: 52px;
    transform: rotate(-5deg);
}

.success-circle-stroke {
    stroke: #fff;
    stroke-width: 3;
}

.success-check-path {
    stroke: #fff;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
}

.success-text {
    color: #fff;
    margin-top: 24px;
    font-size: 18px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes badgePop {
    0% { transform: scale(0) rotate(-45deg); }
    55% { transform: scale(1.15) rotate(8deg); }
    75% { transform: scale(0.95) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes badgeRipple {
    0% { transform: scale(0.8); opacity: 0.6; }
    100% { transform: scale(2.2); opacity: 0; }
}

@keyframes successCheckDraw {
    from { stroke-dashoffset: 48; }
    to { stroke-dashoffset: 0; }
}

@keyframes successTextFade {
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .success-badge {
        width: 80px;
        height: 80px;
    }

    .success-circle {
        width: 70px;
        height: 70px;
    }

    .success-check {
        width: 40px;
        height: 40px;
    }

    .success-text {
        font-size: 16px;
    }
}

/* ---- Dashboard grid ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-top: 24px;
}

.chart-box {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    opacity: 0;
    transform: translateY(60px) scale(0.96);
    filter: blur(8px);
    transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.9s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.9s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.25s ease;
}

.chart-box.wide {
    grid-column: span 2;
}

.chart-box.in-view {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

.chart-box:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px) scale(1.005);
}

.chart-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.chart-header .chart-title {
    margin: 0;
}

.chart-date-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chart-date-filter input[type="date"] {
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text-main);
    background: #fff;
}

.chart-date-filter span {
    font-size: 13px;
    color: #64748b;
}

.chart-box {
    min-height: 360px;
}

.chart-box canvas {
    height: 320px !important;
    width: 100% !important;
}

.chart-box.chart-doughnut canvas {
    height: 260px !important;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .chart-box.wide {
        grid-column: span 1;
    }
}

/* ---- Modales ---- */
.modal-box {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-actions .btn-flex {
    border-radius: var(--radius);
}

/* ---- Botones pequeños ---- */
.btn-sm {
    border-radius: var(--radius);
    width: auto;
    padding: 6px 14px;
    font-weight: 600;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-sm:hover {
    transform: translateY(-1px);
}

.btn-sm:active {
    transform: translateY(1px);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    body::before {
        width: 300px;
        height: 300px;
        filter: blur(80px);
    }

    body::after {
        width: 240px;
        height: 240px;
        filter: blur(80px);
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-card h2 {
        font-size: 22px;
    }

    .kpi-card {
        padding: 16px;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
    }

    .portal-card {
        padding: 20px;
    }

    .glass-card {
        padding: 20px;
    }

    .portal-table th,
    .portal-table td {
        padding: 10px 12px;
        font-size: 12px;
    }

    .actions-cell .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }

    .pagination-wrapper a {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .file-dropzone {
        padding: 20px 16px;
    }

    .portal-table th,
    .portal-table td {
        padding: 8px 10px;
        font-size: 11px;
    }

    .actions-cell .btn-sm {
        display: inline-block;
        margin-bottom: 4px;
    }
}

/* ==========================================================================
   MODO OSCURO  [data-theme="dark"] en <html>
   ========================================================================== */

/* Boton de tema en la barra superior */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0b2a5e;
    transition: background var(--transition-fast), color var(--transition-fast);
    padding: 0;
}

.theme-toggle:hover {
    background: rgba(11, 42, 94, 0.08);
}

.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Variables en oscuro */
[data-theme="dark"] {
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
}

/* Barra superior */
[data-theme="dark"] .top-bar {
    background: #0f172a;
    color: #e2e8f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .top-bar .nav-links a,
[data-theme="dark"] .top-bar .nav-links button {
    color: #e2e8f0;
}

[data-theme="dark"] .top-bar .nav-links a:hover,
[data-theme="dark"] .top-bar .nav-links button:hover {
    color: #fca5a5;
}

[data-theme="dark"] .user-info,
[data-theme="dark"] .user-icon {
    color: #e2e8f0;
}

[data-theme="dark"] .theme-toggle { color: #fbbf24; }
[data-theme="dark"] .theme-toggle:hover { background: rgba(251, 191, 36, 0.12); }

/* Fondo general y velo */
[data-theme="dark"] body {
    background: linear-gradient(135deg, #020617 0%, #0a192f 100%);
    color: #e2e8f0;
}

[data-theme="dark"] .overlay {
    background: rgba(2, 6, 23, 0.88);
}

/* Superficies / tarjetas */
[data-theme="dark"] .glass-card,
[data-theme="dark"] .auth-card,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .chart-box,
[data-theme="dark"] .modal-box,
[data-theme="dark"] .portal-card,
[data-theme="dark"] .panel-row,
[data-theme="dark"] .panel-section-body,
[data-theme="dark"] .description-box,
[data-theme="dark"] .auth-success-box,
[data-theme="dark"] .detail-row,
[data-theme="dark"] .ticket-detail-header {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(148, 163, 184, 0.18);
    color: #e2e8f0;
}

[data-theme="dark"] .auth-token-invalid {
    background: rgba(120, 30, 30, 0.3);
    color: #fca5a5;
}

/* Titulos y textos */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] .home-title,
[data-theme="dark"] .home-subtitle,
[data-theme="dark"] .auth-card > p,
[data-theme="dark"] .detail-label,
[data-theme="dark"] label,
[data-theme="dark"] .auth-rules li,
[data-theme="dark"] .auth-hint,
[data-theme="dark"] .panel-row,
[data-theme="dark"] .panel-row span,
[data-theme="dark"] .kpi-card h2,
[data-theme="dark"] .kpi-card .kpi-value,
[data-theme="dark"] .kpi-card .kpi-label {
    color: #e2e8f0;
}

[data-theme="dark"] .auth-footer,
[data-theme="dark"] .auth-footer-links,
[data-theme="dark"] .auth-options label {
    color: #94a3b8;
}

[data-theme="dark"] .auth-footer-links a,
[data-theme="dark"] .auth-options a,
[data-theme="dark"] .auth-footer a {
    color: #93c5fd;
}

/* Inputs */
[data-theme="dark"] .form-input,
[data-theme="dark"] .modal-input,
[data-theme="dark"] .modal-select,
[data-theme="dark"] .modal-textarea,
[data-theme="dark"] .auth-input-wrapper input,
[data-theme="dark"] .auth-input-wrapper select {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .form-input::placeholder,
[data-theme="dark"] .modal-input::placeholder,
[data-theme="dark"] .auth-input-wrapper input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .modal-input:focus,
[data-theme="dark"] .modal-select:focus,
[data-theme="dark"] .modal-textarea:focus,
[data-theme="dark"] .auth-input-wrapper input:focus,
[data-theme="dark"] .auth-input-wrapper select:focus {
    border-color: #3b82f6;
    background: #16213a;
}

[data-theme="dark"] select option {
    background: #1e293b;
    color: #e2e8f0;
}

[data-theme="dark"] .auth-input-icon,
[data-theme="dark"] .auth-toggle-password {
    color: #94a3b8;
}

/* Tablas */
[data-theme="dark"] .portal-table {
    border-color: #334155;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .portal-table thead tr {
    background: #0a192f;
}

[data-theme="dark"] .portal-table td {
    color: #e2e8f0;
    border-bottom-color: #334155;
}

[data-theme="dark"] .portal-table tbody tr:nth-child(odd)  { background: #0f172a; }
[data-theme="dark"] .portal-table tbody tr:nth-child(even) { background: #16213a; }
[data-theme="dark"] .portal-table tbody tr:hover            { background: #1e3a5f; }

[data-theme="dark"] .portal-table.table-fixed th,
[data-theme="dark"] .portal-table.table-fixed td {
    border-color: #334155;
}

/* Paginacion */
[data-theme="dark"] .pagination a,
[data-theme="dark"] .pagination span {
    color: #e2e8f0;
    background: #1e293b;
    border-color: #334155;
}

/* Cajas de busqueda del panel */
[data-theme="dark"] .search-box input,
[data-theme="dark"] .actions-header input,
[data-theme="dark"] .panel-search input {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

/* Bordes genericos claros -> oscuros */
[data-theme="dark"] .detail-row,
[data-theme="dark"] .panel-row {
    border-color: rgba(148, 163, 184, 0.18);
}

/* Imagenes del ticket */
[data-theme="dark"] .images-grid img {
    border-color: #334155;
}

/* Descripcion del ticket */
[data-theme="dark"] .description-box.description-success {
    background: rgba(20, 60, 40, 0.4);
    border-color: rgba(52, 211, 153, 0.3);
}

/* ==========================================================================
   MODO OSCURO - segunda pasada: controles de formulario, perfil, tarjetas
   ========================================================================== */
[data-theme="dark"] .profile-field .value {
    background: #16213a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .profile-field label {
    color: #7ab3ff;
}

/* Formularios del portal (crear ticket, filtros, genericos) */
[data-theme="dark"] .portal-form input,
[data-theme="dark"] .portal-form select,
[data-theme="dark"] .portal-form textarea,
[data-theme="dark"] .form-control,
[data-theme="dark"] .search-form .search-input {
    background: #16213a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .portal-form select:disabled,
[data-theme="dark"] .modal-select:disabled {
    background: #101a2c;
    color: #64748b;
}
[data-theme="dark"] .portal-form input:focus,
[data-theme="dark"] .portal-form select:focus,
[data-theme="dark"] .portal-form textarea:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .search-form .search-input:focus {
    background: #1b2a47;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}
[data-theme="dark"] .portal-form input::placeholder,
[data-theme="dark"] .portal-form textarea::placeholder,
[data-theme="dark"] .search-form .search-input::placeholder {
    color: #5b6b85;
}

/* Dropzone de adjuntos */
[data-theme="dark"] .file-dropzone {
    background: #101a2c;
    border-color: #334155;
}
[data-theme="dark"] .file-dropzone:hover {
    background: #16213a;
    border-color: #3b82f6;
}
[data-theme="dark"] .file-dropzone.dragover {
    background: #2a1220;
    border-color: var(--accent);
}
[data-theme="dark"] .file-dropzone .dropzone-icon { color: #7ab3ff; }
[data-theme="dark"] .file-dropzone .dropzone-text { color: #e2e8f0; }
[data-theme="dark"] .file-dropzone .dropzone-hint { color: #94a3b8; }

/* Lista de archivos adjuntos */
[data-theme="dark"] .file-item {
    background: #16213a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .file-item .file-remove {
    background: rgba(227, 6, 19, 0.18);
    color: #ff6b74;
}
[data-theme="dark"] .file-item .file-remove:hover {
    background: rgba(227, 6, 19, 0.3);
}

/* Tarjetas del home: icono y link */
[data-theme="dark"] .portal-card .icon { color: #7ab3ff; }
[data-theme="dark"] .portal-card .link-text { color: #7ab3ff; }
[data-theme="dark"] .portal-card:hover .link-text { color: #a8ccff; }

/* Detalle de ticket */
[data-theme="dark"] .detail-value { color: #e2e8f0; }
[data-theme="dark"] .detail-label { color: #94a3b8; }
[data-theme="dark"] .description-box {
    background: #16213a;
    border-left-color: #3b82f6;
    color: #dbe4f0;
}
[data-theme="dark"] .no-images { color: #64748b; }

/* Paginacion */
[data-theme="dark"] .pagination-info { color: #cbd5e1; }
[data-theme="dark"] .pagination-wrapper a {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .pagination-wrapper a:hover { background: #e30613; }

/* Modales */
[data-theme="dark"] .modal-field-label { color: #7ab3ff; }
[data-theme="dark"] .modal-close { color: #94a3b8; }
[data-theme="dark"] .modal-close:hover { color: #e2e8f0; }
[data-theme="dark"] .modal-checkbox-row label { color: #cbd5e1; }
[data-theme="dark"] .modal-actions .btn-cancel {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
[data-theme="dark"] .modal-actions .btn-cancel:hover {
    background: #26334a;
    color: #f1f5f9;
}
[data-theme="dark"] .modal-overlay { background: rgba(2, 6, 23, 0.7); }

/* Panel de administracion */
[data-theme="dark"] .panel-section { border-color: #334155; }
[data-theme="dark"] .panel-section-header {
    background: #16213a;
    color: #7ab3ff;
}
[data-theme="dark"] .modal-input {
    background: #16213a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .modal-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

/* Prioridad P3: azul oscuro -> azul claro para contraste */
[data-theme="dark"] .priority-p3 { color: #7ab3ff; }

/* Botones de tabla y portal */
[data-theme="dark"] .btn-sm,
[data-theme="dark"] a.btn-sm,
[data-theme="dark"] button.btn-sm,
[data-theme="dark"] input[type="submit"].btn-sm {
    background: #1e5bc2 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .btn-sm:hover,
[data-theme="dark"] a.btn-sm:hover,
[data-theme="dark"] button.btn-sm:hover {
    background: #3b82f6 !important;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}
[data-theme="dark"] .btn-sm-danger { background: #b91c1c !important; }
[data-theme="dark"] .btn-sm-danger:hover { background: #e30613 !important; }

/* Dashboard */
[data-theme="dark"] .chart-box {
    background: #131f36;
    border-top-color: #3b82f6;
}
[data-theme="dark"] .chart-title,
[data-theme="dark"] .chart-header h2,
[data-theme="dark"] .chart-header h3 { color: #e2e8f0; }
[data-theme="dark"] .chart-date-filter input,
[data-theme="dark"] .chart-date-filter select {
    background: #16213a;
    border-color: #334155;
    color: #e2e8f0;
}

/* Imagen modal */
[data-theme="dark"] .image-modal { background: rgba(2, 6, 23, 0.9); }
[data-theme="dark"] .image-modal-close { color: #e2e8f0; }

/* Exito de creacion */
[data-theme="dark"] .success-text { color: #e2e8f0; }

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar { width: 10px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f172a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #334155; border-radius: 5px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Logo de la barra: version normal en claro, version blanca en oscuro */
.brand-logo .logo-dark { display: none; }
[data-theme="dark"] .brand-logo .logo-light { display: none; }
[data-theme="dark"] .brand-logo .logo-dark { display: inline; }

/* Tarjetas del home en oscuro: iconos y enlaces en blanco como el texto */
[data-theme="dark"] .portal-card .icon { color: #ffffff; }
[data-theme="dark"] .portal-card .link-text { color: #ffffff; }
[data-theme="dark"] .portal-card:hover .link-text { color: #ffffff; text-decoration: underline; }

/* ==========================================================================
   MODO OSCURO - tercera pasada: texto claro en TODOS los componentes
   ========================================================================== */
[data-theme="dark"] body,
[data-theme="dark"] .portal-card,
[data-theme="dark"] .glass-card,
[data-theme="dark"] .portal-table td,
[data-theme="dark"] .file-item,
[data-theme="dark"] .detail-value,
[data-theme="dark"] .panel-row-name,
[data-theme="dark"] .modal-checkbox-row label,
[data-theme="dark"] .auth-input-wrapper input,
[data-theme="dark"] .auth-input-wrapper select,
[data-theme="dark"] .auth-options label,
[data-theme="dark"] .pagination-info,
[data-theme="dark"] .chart-title,
[data-theme="dark"] .chart-date-filter input[type="date"] {
    color: #e2e8f0;
}

/* Titulos de secciones del panel (USUARIOS, CATEGORIAS, etc.) en blanco */
[data-theme="dark"] .panel-section-header {
    color: #ffffff;
}

/* Textos secundarios: gris claro legible */
[data-theme="dark"] .portal-card p,
[data-theme="dark"] .detail-label,
[data-theme="dark"] .no-images,
[data-theme="dark"] .auth-hint,
[data-theme="dark"] .file-dropzone,
[data-theme="dark"] .file-dropzone .dropzone-hint,
[data-theme="dark"] .action-icon,
[data-theme="dark"] .chart-date-filter span,
[data-theme="dark"] .modal-close {
    color: #94a3b8;
}
[data-theme="dark"] .action-icon:hover { color: #ffffff; }

/* Enlaces y acentos: azul claro */
[data-theme="dark"] .panel-row-actions a,
[data-theme="dark"] .auth-options a,
[data-theme="dark"] .auth-footer-links a,
[data-theme="dark"] .auth-footer a {
    color: #7ab3ff;
}
[data-theme="dark"] .panel-row-actions a:hover,
[data-theme="dark"] .auth-options a:hover,
[data-theme="dark"] .auth-footer-links a:hover,
[data-theme="dark"] .auth-footer a:hover {
    color: #a8ccff;
}

/* Iconos y labels de formularios/auth */
[data-theme="dark"] .auth-input-icon,
[data-theme="dark"] .auth-toggle-password,
[data-theme="dark"] .auth-input-group label,
[data-theme="dark"] .auth-card h1 {
    color: #cbd5e1;
}
[data-theme="dark"] .auth-input-wrapper input:focus,
[data-theme="dark"] .auth-input-wrapper select:focus {
    color: #ffffff;
}

/* KPI: el texto dentro de tarjetas de color se mantiene blanco */
[data-theme="dark"] .kpi-card h2,
[data-theme="dark"] .kpi-card h3,
[data-theme="dark"] .kpi-card .kpi-value,
[data-theme="dark"] .kpi-card .kpi-label {
    color: #ffffff;
}
[data-theme="dark"] .kpi-anulados .kpi-icon { color: #94a3b8; }

/* Logo segun tema: generico (topbar + tarjetas de login/registro) */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: inline-block; }
