﻿:root {
    --bg-base: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f1f3f5;
    --border: #e9ecef;
    --border-light: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --amber: #f59e0b;
    --amber-dim: #fef3c7;
    --amber-glow: rgba(245,158,11,0.08);
    --green: #22c55e;
    --green-dim: #dcfce7;
    --blue: #3b82f6;
    --blue-dim: #dbeafe;
    --red: #ef4444;
    --red-dim: #fee2e2;
    --purple: #a78bfa;
    --purple-dim: #ede9fe;
    --orange: #f97316;
    --orange-dim: #ffedd5;
    --sidebar-w: 240px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── APP SHELL ──────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--amber);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.brand-name {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: block;
    line-height: 1;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0;
    display: block;
    margin-top: 3px;
    font-weight: 400;
}

.nav-links {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

    .nav-links li {
        margin-bottom: 2px;
    }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

    .nav-link:hover {
        background: var(--bg-elevated);
        color: var(--text-primary);
    }

    .nav-link.active {
        background: var(--amber-dim);
        color: var(--amber);
        border: 1px solid rgba(245,158,11,0.2);
    }

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.version-tag {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-base);
}

.content-wrapper {
    padding: 32px 36px;
    max-width: 1400px;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 400;
}

.back-link {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    margin-bottom: 8px;
    transition: color 0.15s;
}

    .back-link:hover {
        color: var(--amber);
    }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn-primary-action {
    background: var(--amber);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

    .btn-primary-action:hover {
        background: #d97706;
    }

    .btn-primary-action:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

    .btn-secondary:hover {
        background: var(--bg-elevated);
        border-color: var(--border-light);
    }

    .btn-secondary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-danger {
    background: var(--red);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

    .btn-danger:hover {
        background: #dc2626;
    }

    .btn-danger:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-danger-outline {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.3);
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

    .btn-danger-outline:hover {
        background: var(--red-dim);
    }

.btn-link {
    color: var(--amber);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.15s;
}

    .btn-link:hover {
        opacity: 0.75;
    }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

    .btn-icon:hover {
        color: var(--text-primary);
        background: var(--bg-elevated);
    }

    .btn-icon.btn-delete:hover {
        color: var(--red);
        border-color: rgba(239,68,68,0.4);
        background: var(--red-dim);
    }

    .btn-icon.btn-assign:hover {
        color: var(--green);
        border-color: rgba(34,197,94,0.4);
        background: var(--green-dim);
    }

    .btn-icon.btn-release:hover {
        color: var(--orange);
        border-color: rgba(249,115,22,0.4);
        background: var(--orange-dim);
    }

.action-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── STATS GRID (NEW DESIGN) ────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

    .stat-card:hover {
        box-shadow: var(--shadow-lg);
    }

    .stat-card .stat-label {
        font-size: 13px;
        color: var(--text-secondary);
        font-weight: 500;
        display: block;
        margin-bottom: 12px;
    }

    .stat-card .stat-value {
        font-size: 36px;
        font-weight: 700;
        display: block;
        line-height: 1;
        color: var(--text-primary);
    }

    .stat-card .stat-icon {
        display: none;
    }

/* Stats variations */
.stat-disponible .stat-value {
    color: var(--green);
}

.stat-asignado .stat-value {
    color: var(--blue);
}

.stat-mantenimiento .stat-value {
    color: var(--orange);
}

.stat-baja .stat-value {
    color: var(--text-muted);
}

/* ── TABLE ──────────────────────────────────────────────────── */
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

    .data-table thead {
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border);
    }

    .data-table th {
        padding: 12px 16px;
        text-align: left;
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        color: var(--text-secondary);
        letter-spacing: 0.05em;
    }

    .data-table td {
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
        color: var(--text-secondary);
        vertical-align: middle;
        font-size: 14px;
    }

    .data-table tr:last-child td {
        border-bottom: none;
    }

    .data-table tbody tr:hover td {
        background: var(--bg-elevated);
    }

    .data-table tr.row-baja td {
        opacity: 0.5;
    }

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

.table-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

.cell-main {
    color: var(--text-primary);
    font-weight: 600;
}

.cell-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── BADGES ─────────────────────────────────────────────────── */
.serial-badge {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--text-primary);
}

.status-badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: capitalize;
    padding: 4px 12px;
    border-radius: 16px;
    display: inline-block;
}

.status-disponible {
    background: var(--green-dim);
    color: #15803d;
}

.status-asignado {
    background: var(--blue-dim);
    color: #1d4ed8;
}

.status-enmantenimiento {
    background: var(--orange-dim);
    color: #c2410c;
}

.status-dadobaja {
    background: var(--red-dim);
    color: #b91c1c;
}

/* ── ACCESSORIES ─────────────────────────────────────────────── */
.accesorio-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.acc-tag {
    font-size: 11px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 500;
}

    .acc-tag.acc-more {
        color: var(--amber);
        border-color: var(--amber);
        background: var(--amber-dim);
    }

.accesorio-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.accesorio-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.acc-icon {
    color: var(--amber);
    font-size: 14px;
    margin-top: 2px;
}

.acc-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.acc-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── FILTER BAR ──────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 220px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px 10px 38px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.15s;
}

    .search-input:focus {
        outline: none;
        border-color: var(--amber);
    }

    .search-input::placeholder {
        color: var(--text-muted);
    }

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.select-filter {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 9px 12px;
    font-size: 14px;
    cursor: pointer;
}

    .select-filter:focus {
        outline: none;
        border-color: var(--amber);
    }

/* ── DASHBOARD SECTION ────────────────────────────────────────── */
.dashboard-section {
    margin-top: 36px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* ── FORMS ───────────────────────────────────────────────────── */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 760px;
}

.form-card, .detail-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.card-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    margin-top: -12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

    .form-group label {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-primary);
    }

.form-input, .select-input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color 0.15s;
    resize: vertical;
}

    .form-input:focus, .select-input:focus {
        outline: none;
        border-color: var(--amber);
    }

    .form-input::placeholder {
        color: var(--text-muted);
    }

    .form-input.input-error {
        border-color: var(--red);
    }

.field-error {
    font-size: 12px;
    color: var(--red);
}

.form-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

    .form-check input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: var(--amber);
        cursor: pointer;
    }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 4px;
}

.accessory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.accessory-option {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

    .accessory-option:hover {
        border-color: var(--border-light);
        background: var(--bg-elevated);
    }

    .accessory-option.selected {
        background: var(--amber-dim);
        border-color: var(--amber);
    }

.acc-check {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: transparent;
    flex-shrink: 0;
    transition: all 0.15s;
}

.accessory-option.selected .acc-check {
    background: var(--amber);
    border-color: var(--amber);
    color: #fff;
    font-weight: 700;
}

/* ── DETAIL VIEW ─────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-card-full {
    grid-column: 1 / -1;
}

.detail-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

    .detail-row:last-child {
        border-bottom: none;
    }

.detail-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── MODALS ──────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    animation: slideUp 0.2s ease;
}

    .modal-card.modal-sm {
        max-width: 380px;
    }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

    .modal-header h3 {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
    }

.modal-header-danger {
    background: var(--red-dim);
}

    .modal-header-danger h3 {
        color: var(--red);
    }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
}

    .modal-close:hover {
        color: var(--text-primary);
    }

.modal-body {
    padding: 20px 24px;
}

.modal-info {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert-error {
    background: var(--red-dim);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--red);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    margin-top: 12px;
}

.confirm-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin: 8px 0;
    font-size: 14px;
}

.confirm-warning {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ── TOAST ───────────────────────────────────────────────────── */
.toast-success {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--green);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(34,197,94,0.3);
    z-index: 2000;
    animation: slideUp 0.2s ease;
}

/* ── STATES ──────────────────────────────────────────────────── */
.loading-state {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 48px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    text-align: center;
    padding: 64px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-icon {
    font-size: 48px;
    color: var(--text-muted);
    opacity: 0.4;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
}

.empty-state-sm {
    padding: 16px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.not-found {
    text-align: center;
    padding: 64px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 13px;
}

/* ── BLAZOR ERROR ────────────────────────────────────────────── */
#blazor-error-ui {
    background: var(--red-dim);
    border: 1px solid rgba(239,68,68,0.4);
    color: var(--red);
    padding: 12px 20px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    z-index: 9999;
}

    #blazor-error-ui .reload, #blazor-error-ui .dismiss {
        color: var(--amber);
        text-decoration: underline;
        cursor: pointer;
        margin-left: 12px;
    }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .content-wrapper {
        padding: 20px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
