/* Intranet UI shared components */

:root,
html[data-theme='light'],
body[data-theme='light'] {
    --theme-ink-900: #0f2a43;
    --theme-ink-700: #2d4c66;
    --theme-line: #d4e0ea;
    --theme-line-soft: #d8e5ef;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f6fbff;
    --theme-surface-subtle: #f5f5f5;
    --theme-page-bg-gradient: radial-gradient(circle at 4% 4%, rgba(165, 203, 228, 0.28), transparent 34%), linear-gradient(145deg, #eaf2f8, #f7fbff 45%, #ecf4fa);
    --theme-auth-bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --theme-accent: #0f7ccc;
    --theme-accent-2: #1b5ea7;
    --theme-accent-soft: #0b6aa5;
    --theme-focus: #1a8de0;
    --theme-ok: #0f7a58;
    --theme-warn: #9b321f;

    --theme-success-bg: #d4edda;
    --theme-success-border: #c3e6cb;
    --theme-success-text: #155724;
    --theme-danger-bg: #f8d7da;
    --theme-danger-border: #f5c6cb;
    --theme-danger-text: #721c24;
    --theme-info-bg: #d1ecf1;
    --theme-info-border: #bee5eb;
    --theme-info-text: #0c5460;

    --theme-auth-primary: #667eea;
    --theme-auth-secondary: #764ba2;
    --theme-text-neutral: #333333;
    --theme-text-muted: #999999;

    --ink-900: var(--theme-ink-900);
    --ink-700: var(--theme-ink-700);
    --line: var(--theme-line);
    --surface: var(--theme-surface);
    --surface-soft: var(--theme-surface-soft);
    --ok: var(--theme-ok);
    --warn: var(--theme-warn);
    --focus: var(--theme-focus);
    --accent: var(--theme-accent);
    --accent-2: var(--theme-accent-2);
    --bg: #f2f7fb;
    --card: var(--theme-surface);

    --ncs-blue-900: #062848;
    --ncs-blue-700: #0b4e82;
    --ncs-blue-500: #1274b8;
    --ncs-cyan-200: #a5e4ff;
    --ncs-cyan-300: #5ac7ff;

    /* Compatibility aliases enforced for legacy per-page variables */
    --text-strong: var(--theme-ink-900) !important;
    --text-soft: var(--theme-ink-700) !important;
    --surface-edge: var(--theme-line-soft) !important;
    --error: var(--theme-danger-text) !important;
    --success: var(--theme-success-text) !important;
}

html[data-theme='dark'],
body[data-theme='dark'] {
    --theme-ink-900: #e8f1fb;
    --theme-ink-700: #b8c9dc;
    --theme-line: #35516b;
    --theme-line-soft: #486987;
    --theme-surface: #122235;
    --theme-surface-soft: #1a2f47;
    --theme-surface-subtle: #24384f;
    --theme-page-bg-gradient: radial-gradient(circle at 7% 5%, rgba(47, 94, 137, 0.35), transparent 33%), linear-gradient(145deg, #0a1726, #102237 48%, #15314d);
    --theme-auth-bg-gradient: linear-gradient(135deg, #243b7d 0%, #422962 100%);

    --theme-accent: #57a8e6;
    --theme-accent-2: #3d91d0;
    --theme-accent-soft: #4e9dd9;
    --theme-focus: #74c3ff;
    --theme-ok: #5fcf9d;
    --theme-warn: #ff8f70;

    --theme-success-bg: rgba(35, 88, 62, 0.6);
    --theme-success-border: #3f8f67;
    --theme-success-text: #b8f2d3;
    --theme-danger-bg: rgba(99, 41, 48, 0.6);
    --theme-danger-border: #b9646d;
    --theme-danger-text: #ffd2d6;
    --theme-info-bg: rgba(25, 66, 90, 0.6);
    --theme-info-border: #5b9ac1;
    --theme-info-text: #c6ebff;

    --theme-auth-primary: #7fa7ff;
    --theme-auth-secondary: #a57ed6;
    --theme-text-neutral: #dbe8f7;
    --theme-text-muted: #9fb4cb;

    --bg: #0f1f30;
    --card: var(--theme-surface);
    --ncs-blue-900: #12263d;
    --ncs-blue-700: #1a3a58;
    --ncs-blue-500: #25517a;
    --ncs-cyan-200: #70b8dd;
    --ncs-cyan-300: #7bd0f6;

    /* Compatibility aliases enforced for legacy per-page variables */
    --text-strong: var(--theme-ink-900) !important;
    --text-soft: var(--theme-ink-700) !important;
    --surface-edge: var(--theme-line-soft) !important;
    --error: var(--theme-danger-text) !important;
    --success: var(--theme-success-text) !important;
}

body {
    color: var(--theme-ink-900);
}

/* Global form and card defaults to reduce per-page style duplication */
input,
select,
textarea {
    color: var(--theme-ink-900);
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    border-color: var(--theme-line-soft);
    background: var(--theme-surface-soft);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--theme-focus);
}

/* Standardized opt-in form system to keep controls aligned across modules */
.ui-form-standard {
    --ui-control-height: 2.75rem;
    --ui-control-radius: 10px;
    --ui-control-padding-x: 0.75rem;
    --ui-control-padding-y: 0.68rem;
    --ui-form-gap: 0.85rem;
}

.ui-form-standard .ui-field-grid,
.ui-form-standard .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--ui-form-gap);
    align-items: start;
}

.ui-form-standard .ui-field,
.ui-form-standard .field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.ui-form-standard .ui-label,
.ui-form-standard label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--theme-ink-700);
}

.ui-form-standard :is(input:not([type='hidden']):not([type='checkbox']):not([type='radio']):not([type='file']), select, textarea, .ui-control) {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    height: var(--ui-control-height);
    min-height: var(--ui-control-height);
    padding: var(--ui-control-padding-y) var(--ui-control-padding-x);
    border: 1px solid var(--theme-line-soft);
    border-radius: var(--ui-control-radius);
    background: var(--theme-surface-soft);
    color: var(--theme-ink-900);
    font: inherit;
    line-height: 1.3;
}

.ui-form-standard select,
.ui-form-standard .ui-control-select {
    height: var(--ui-control-height);
    line-height: 1.3;
}

.ui-form-standard textarea,
.ui-form-standard .ui-control-textarea {
    height: auto;
    min-height: calc(var(--ui-control-height) * 2.25);
    resize: vertical;
}

.ui-form-standard :is(input:not([type='hidden']):not([type='checkbox']):not([type='radio']):not([type='file']), select, textarea, .ui-control):focus {
    outline: none;
    border-color: var(--theme-focus);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-focus) 22%, transparent);
    background: var(--theme-surface);
}

.ui-form-standard :is(input:not([type='hidden']):not([type='checkbox']):not([type='radio']):not([type='file']), select, textarea, .ui-control):disabled {
    opacity: 0.78;
    cursor: not-allowed;
}

.ui-form-standard .ui-actions,
.ui-form-standard .actions {
    margin-top: 0.95rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.ui-form-standard .btn,
.ui-form-standard .ui-btn {
    min-height: calc(var(--ui-control-height) - 0.2rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

@media (max-width: 980px) {
    .ui-form-standard .ui-field-grid,
    .ui-form-standard .form-grid {
        grid-template-columns: 1fr;
    }
}

.ui-surface {
    background: var(--theme-surface);
    border: 1px solid var(--theme-line-soft);
    color: var(--theme-ink-900);
}

.ui-soft {
    background: var(--theme-surface-soft);
    border: 1px solid var(--theme-line-soft);
    color: var(--theme-ink-700);
}

.ui-muted {
    color: var(--theme-ink-700);
}

.theme-toggle-inline,
.theme-toggle-floating {
    cursor: pointer;
}

.theme-toggle-inline {
    border-radius: 999px;
    padding-inline: 0.78rem;
}

.theme-toggle-inline .theme-toggle-icon,
.theme-toggle-inline .theme-toggle-label {
    transition: transform 120ms ease, opacity 120ms ease;
}

.theme-toggle-inline.is-dark .theme-toggle-icon {
    transform: rotate(14deg);
}

.theme-toggle-floating {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 995;
    border: 1px solid var(--theme-line-soft);
    background: var(--theme-surface);
    color: var(--theme-ink-900);
    border-radius: 999px;
    padding: 0.45rem 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 10px 18px rgba(10, 39, 66, 0.16);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
}

.theme-toggle-track {
    width: 2.35rem;
    height: 1.25rem;
    border-radius: 999px;
    border: 1px solid var(--theme-line-soft);
    background: var(--theme-surface-soft);
    position: relative;
    display: inline-flex;
    align-items: center;
}

.theme-toggle-thumb {
    width: 0.95rem;
    height: 0.95rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--theme-accent), var(--theme-accent-2));
    transform: translateX(0.13rem);
    transition: transform 160ms ease;
}

.theme-toggle-floating.is-dark .theme-toggle-thumb {
    transform: translateX(1.13rem);
}

.theme-toggle-floating:hover,
.theme-toggle-inline:hover {
    border-color: var(--theme-accent);
}

@media (max-width: 640px) {
    .theme-toggle-floating {
        left: 0.75rem;
        bottom: 0.75rem;
        padding: 0.4rem 0.62rem;
    }
}

.hero {
    margin-bottom: 1rem;
    border-radius: 18px;
    padding: 1rem 1.2rem;
    background: linear-gradient(180deg, var(--theme-surface), var(--theme-surface-soft));
    border: 1px solid var(--theme-line);
    box-shadow: 0 10px 24px rgba(17, 59, 91, 0.08);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
}

.hero h2 {
    font-size: clamp(1.35rem, 1rem + 0.8vw, 1.8rem);
    line-height: 1.2;
    margin: 0;
    color: var(--theme-ink-900);
    text-align: center;
}

.hero-nav-left,
.hero-nav-right {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.hero-nav-right {
    justify-content: flex-end;
}

.hero-link {
    display: inline-flex;
    align-items: center;
    gap: 0.36rem;
    padding: 0.46rem 0.62rem;
    border-radius: 10px;
    border: 1px solid var(--theme-line);
    background: var(--theme-surface-soft);
    color: var(--theme-ink-900);
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.hero-link:hover {
    border-color: var(--theme-accent);
    background: var(--theme-surface);
}

.hero-link-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    font-size: 0.95rem;
    line-height: 1;
}

.form-actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    justify-content: center;
    margin-top: 1.25rem;
}

.btn-primary {
    cursor: pointer;
    border: none;
    font-weight: 800;
    padding: 0.92rem 1.2rem;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--theme-accent), var(--theme-accent-2));
    box-shadow: 0 12px 20px rgba(7, 86, 145, 0.23);
    min-width: 190px;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.fab-plus {
    position: fixed;
    right: 1.2rem;
    bottom: 1.2rem;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--theme-accent-2), var(--theme-accent));
    color: #fff;
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 8px 18px rgba(9, 80, 132, 0.35);
    border: 0;
    z-index: 999;
    cursor: pointer;
}

.fab-plus:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(9, 80, 132, 0.45);
}

@media (max-width: 900px) {
    .hero-link-label {
        display: none;
    }

    .hero-link {
        min-width: 2.05rem;
        justify-content: center;
        padding: 0.48rem;
    }
}

@media (max-width: 640px) {
    .hero {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .hero-nav-left,
    .hero-nav-right {
        justify-content: center;
        flex-wrap: wrap;
    }

    .hero-nav-right {
        order: 3;
    }

    .hero h2 {
        order: 1;
    }

    .hero-nav-left {
        order: 2;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary {
        width: 100%;
    }
}

/* Dark mode — legacy status badge colors (no need for base variables, they inherit from :root) */
body[data-theme='dark'] {
    --status-pendiente-bg: rgba(86, 109, 133, 0.26) !important;
    --status-pendiente-text: #c6d5e6 !important;
    --status-pendiente-border: #607a95 !important;

    --status-proceso-bg: rgba(44, 112, 196, 0.24) !important;
    --status-proceso-text: #b9d9ff !important;
    --status-proceso-border: #3f7fc0 !important;

    --status-piezas-bg: rgba(153, 98, 31, 0.24) !important;
    --status-piezas-text: #ffd9a6 !important;
    --status-piezas-border: #b9833e !important;

    --status-completado-bg: rgba(48, 124, 92, 0.24) !important;
    --status-completado-text: #b8f2d3 !important;
    --status-completado-border: #4aa479 !important;

    --status-cancelado-bg: rgba(143, 62, 72, 0.24) !important;
    --status-cancelado-text: #ffd1d6 !important;
    --status-cancelado-border: #bf707b !important;
}

body[data-theme='dark'] table tr:hover td,
body[data-theme='dark'] tbody tr:hover {
    background: rgba(31, 73, 112, 0.16) !important;
}

/* ===== FLASH MESSAGES (light) ===== */
.flash {
    border-radius: 10px;
    padding: 0.72rem 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    font-size: 0.92rem;
}

.flash.success {
    background: var(--theme-success-bg);
    border-color: var(--theme-success-border);
    color: var(--theme-success-text);
}

.flash.error {
    background: var(--theme-danger-bg);
    border-color: var(--theme-danger-border);
    color: var(--theme-danger-text);
}

body[data-theme='dark'] .flash.success,
body[data-theme='dark'] .status-active,
body[data-theme='dark'] .chip.ok {
    background: var(--theme-success-bg) !important;
    border-color: var(--theme-success-border) !important;
    color: var(--theme-success-text) !important;
}

body[data-theme='dark'] .flash.error,
body[data-theme='dark'] .status-expired,
body[data-theme='dark'] .btn-danger,
body[data-theme='dark'] .btn-danger-sm {
    background: var(--theme-danger-bg) !important;
    border-color: var(--theme-danger-border) !important;
    color: var(--theme-danger-text) !important;
}

/* ===== FILTER SYSTEM (tarjetas filtrables) ===== */
.filter-controls {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.6rem 0;
}

.filter-btn {
    border: 2px solid var(--theme-line-soft);
    background: var(--theme-surface);
    color: var(--theme-accent-2);
    border-radius: 20px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: capitalize;
}

.filter-btn:hover {
    border-color: var(--theme-accent);
    background: var(--theme-surface-soft);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--theme-accent), var(--theme-accent-2));
    color: var(--theme-surface);
    border-color: var(--theme-accent-2);
}

.filter-btn.active .stats-badge {
    background: rgba(255, 255, 255, 0.3);
    color: var(--theme-surface);
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.6rem;
    background: var(--theme-surface-soft);
    color: var(--theme-accent-2);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.3rem;
}

/* ===== CARD GRID (detalles / tarjetas) ===== */
.detalles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.detalle-card {
    background: var(--theme-surface);
    border: 1px solid var(--theme-line-soft);
    border-radius: 10px;
    padding: 1rem;
    transition: all 0.2s ease;
    border-left: 4px solid var(--theme-accent-2);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
}

.detalle-card:hover {
    box-shadow: 0 8px 16px rgba(17, 59, 91, 0.12);
    transform: translateY(-2px);
}

.detalle-card.hidden {
    display: none;
}

.detalle-card.type-hardware {
    border-left-color: var(--theme-danger-border);
}

.detalle-card.type-red {
    border-left-color: var(--theme-info-border);
}

.detalle-card.type-software {
    border-left-color: var(--theme-accent);
}

.detalle-card.type-mantenimiento {
    border-left-color: var(--theme-success-border);
}

.detalle-card.type-otro {
    border-left-color: var(--theme-line-soft);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
}

.card-badge {
    display: inline-flex;
    align-items: center;
    background: var(--theme-surface-soft);
    color: var(--theme-accent-2);
    border: 1px solid var(--theme-line-soft);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
    white-space: nowrap;
}

.card-badge.type-hardware {
    background: var(--theme-danger-bg);
    color: var(--theme-danger-text);
    border-color: var(--theme-danger-border);
}

.card-badge.type-red {
    background: var(--theme-info-bg);
    color: var(--theme-info-text);
    border-color: var(--theme-info-border);
}

.card-badge.type-software {
    background: var(--theme-surface-soft);
    color: var(--theme-accent-2);
    border-color: var(--theme-line-soft);
}

.card-badge.type-mantenimiento {
    background: var(--theme-success-bg);
    color: var(--theme-success-text);
    border-color: var(--theme-success-border);
}

.card-badge.type-otro {
    background: var(--theme-surface-soft);
    color: var(--theme-ink-700);
    border-color: var(--theme-line-soft);
}

.card-date {
    color: var(--theme-ink-700);
    font-size: 0.78rem;
    text-align: right;
    min-width: 120px;
}

.card-text {
    color: var(--theme-ink-900);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    flex-grow: 1;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.6rem;
    border-top: 1px solid var(--theme-line-soft);
    color: var(--theme-ink-700);
    font-size: 0.76rem;
}

.card-author {
    font-weight: 600;
    color: var(--theme-ink-700);
}

.card-consumed {
    color: var(--theme-accent-2);
    font-weight: 700;
}

.edit-box {
    margin-top: 0.6rem;
    border-top: 1px solid var(--theme-line-soft);
    padding-top: 0.6rem;
}

.edit-box summary {
    cursor: pointer;
    color: var(--theme-accent-2);
    font-weight: 700;
    font-size: 0.82rem;
}

/* ===== EMPTY STATE ===== */
.empty,
.empty-state {
    color: var(--theme-ink-700);
    border: 1px dashed var(--theme-line-soft);
    border-radius: 10px;
    padding: 0.7rem;
    background: var(--theme-surface-soft);
    font-size: 0.9rem;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    grid-column: 1 / -1;
}

/* ===== ANIMACIONES ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

