/**
 * ============================================================
 * REPORTE DE INCIDENCIAS v2.0 — Componentes UI
 * ============================================================
 * Botones, cards, inputs, modales, toasts, loading states
 */

/* ======================== CARDS ======================== */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

/* Header icon replacement (img instead of SVG) */
.header-icon-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
    flex-shrink: 0;
}

.header-icon-img--brand {
    width: 20px;
    height: 20px;
}

.card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-icon {
    width: 18px;
    height: 18px;
    color: var(--accent-blue);
}

/* ======================== BOTONES ======================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-icon:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ======================== INPUTS ======================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.form-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input,
.form-select {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input[readonly] {
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-secondary);
    cursor: default;
}

/* Custom yellow icon for date inputs */
.form-input[type="date"]::-webkit-calendar-picker-indicator,
.form-input[type="month"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f59e0b'%3E%3Cpath d='M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20a2 2 0 002 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z'/%3E%3C/svg%3E");
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.form-input[type="date"]::-webkit-calendar-picker-indicator:hover,
.form-input[type="month"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 20px;
    padding-right: 32px;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-file-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-input);
    border: 1px dashed var(--border-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.form-file-wrapper:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
}

.form-file-wrapper input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.form-file-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    flex-shrink: 0;
}

.form-file-text {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.form-file-preview {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ======================== TOAST NOTIFICATIONS ======================== */
.toast-container {
    position: fixed;
    top: var(--space-5);
    right: var(--space-5);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    min-width: 320px;
    max-width: 420px;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    animation: slideInRight 0.4s var(--transition-spring) forwards;
    will-change: transform, opacity;
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.toast-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast.toast-success { border-left: 3px solid var(--accent-emerald); }
.toast.toast-success .toast-icon { color: var(--accent-emerald); }
.toast.toast-success .toast-progress { background: var(--accent-emerald); }

.toast.toast-error { border-left: 3px solid var(--accent-red); }
.toast.toast-error .toast-icon { color: var(--accent-red); }
.toast.toast-error .toast-progress { background: var(--accent-red); }

.toast.toast-warning { border-left: 3px solid var(--accent-amber); }
.toast.toast-warning .toast-icon { color: var(--accent-amber); }
.toast.toast-warning .toast-progress { background: var(--accent-amber); }

.toast.toast-info { border-left: 3px solid var(--accent-blue); }
.toast.toast-info .toast-icon { color: var(--accent-blue); }
.toast.toast-info .toast-progress { background: var(--accent-blue); }

.toast-exit {
    animation: toastExit 0.3s ease forwards;
}

@keyframes toastExit {
    to { opacity: 0; transform: translateX(100px); }
}

/* ======================== MODAL ======================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-spring);
    text-align: center;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-5);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.modal-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.modal-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.modal-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

/* ======================== LOADING OVERLAY ======================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-4);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    animation: pulse 1.5s ease-in-out infinite;
}

/* ======================== SKELETON LOADER ======================== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 20px;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

/* ======================== KPI CARDS ======================== */
.kpi-card {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    overflow: hidden;
    transition: all var(--transition-base);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
    border-color: var(--border-strong);
}

.kpi-card .kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.kpi-card .kpi-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1;
    margin-bottom: var(--space-1);
}

.kpi-card .kpi-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-card.blue::before { background: var(--gradient-primary); }
.kpi-card.blue .kpi-icon { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.kpi-card.blue .kpi-value { color: var(--accent-blue); }

.kpi-card.emerald::before { background: var(--gradient-success); }
.kpi-card.emerald .kpi-icon { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.kpi-card.emerald .kpi-value { color: var(--accent-emerald); }

.kpi-card.amber::before { background: var(--gradient-amber); }
.kpi-card.amber .kpi-icon { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.kpi-card.amber .kpi-value { color: var(--accent-amber); }

.kpi-card.cyan::before { background: linear-gradient(135deg, #06b6d4, #8b5cf6); }
.kpi-card.cyan .kpi-icon { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.kpi-card.cyan .kpi-value { color: var(--accent-cyan); }

/* ======================== BADGE ======================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.badge-blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

/* ======================== IMAGE LIGHTBOX ======================== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    display: flex;
    opacity: 1;
}

.lightbox-image {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
    transform: scale(0.9);
    opacity: 0;
    animation: lightbox-zoom-in 0.35s ease forwards;
    cursor: default;
}

@keyframes lightbox-zoom-in {
    to { transform: scale(1); opacity: 1; }
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: var(--glass-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lightbox-nav:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.lightbox-prev { left: var(--space-5); }
.lightbox-next { right: var(--space-5); }

.lightbox-close {
    position: absolute;
    top: var(--space-5);
    right: var(--space-5);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--glass-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lightbox-close:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.lightbox-counter {
    position: absolute;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ======================== FORM STEPPER ======================== */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--space-5);
    padding: 0 var(--space-2);
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.stepper-number {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 700;
    border: 2px solid var(--border);
    color: var(--text-muted);
    background: var(--bg-secondary);
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.stepper-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    transition: color var(--transition-base);
}

.stepper-line {
    width: 30px;
    height: 2px;
    background: var(--border);
    margin: 0 var(--space-1);
    transition: background var(--transition-base);
    flex-shrink: 0;
}

.stepper-step.active .stepper-number {
    background: var(--gradient-primary);
    border-color: var(--accent-blue);
    color: white;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.stepper-step.active .stepper-label {
    color: var(--accent-blue);
}

.stepper-step.completed .stepper-number {
    background: var(--accent-emerald);
    border-color: var(--accent-emerald);
    color: white;
}

.stepper-step.completed .stepper-label {
    color: var(--accent-emerald);
}

.stepper-step.completed + .stepper-line {
    background: var(--accent-emerald);
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

/* ======================== RESPONSIVE COMPONENTS ======================== */

@media screen and (max-width: 768px) {
    /* Toast — full width on mobile */
    .toast-container {
        right: var(--space-3);
        left: var(--space-3);
        top: 64px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
        padding: var(--space-2) var(--space-3);
    }

    .toast-title {
        font-size: var(--text-xs);
    }

    .toast-message {
        font-size: 11px;
    }

    /* Modal — adjusted for small screens */
    .modal {
        padding: var(--space-5);
        max-width: 90vw;
        border-radius: var(--radius-lg);
    }

    .modal-icon {
        width: 48px;
        height: 48px;
    }

    .modal-title {
        font-size: var(--text-lg);
    }

    .modal-message {
        font-size: var(--text-xs);
    }

    .modal-actions {
        flex-direction: column;
        gap: var(--space-2);
    }

    .modal-actions .btn {
        width: 100%;
    }

    /* Lightbox — touch-friendly */
    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev { left: var(--space-2); }
    .lightbox-next { right: var(--space-2); }

    .lightbox-close {
        top: var(--space-3);
        right: var(--space-3);
    }

    /* Buttons — slightly larger touch targets */
    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 36px;
    }

    /* Form inputs — larger tap area */
    .form-input,
    .form-select {
        padding: var(--space-3);
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Cards - less padding */
    .card {
        padding: var(--space-4);
    }

    .card-header {
        margin-bottom: var(--space-3);
    }

    /* KPI cards compact */
    .kpi-card {
        padding: var(--space-3) var(--space-4);
    }

    .kpi-card .kpi-value {
        font-size: var(--text-2xl);
    }

    .kpi-card .kpi-icon {
        width: 36px;
        height: 36px;
    }
}

@media screen and (max-width: 480px) {
    .modal {
        padding: var(--space-4);
        margin: var(--space-3);
    }

    .card {
        padding: var(--space-3);
        border-radius: var(--radius-md);
    }

    .card-header h3 {
        font-size: var(--text-sm);
    }

    /* File upload wrapper */
    .form-file-wrapper {
        padding: var(--space-2);
    }

    .form-file-icon {
        width: 28px;
        height: 28px;
    }

    .form-file-text {
        font-size: 11px;
    }
}

