/* ─── Electrogar-OS Custom Styles ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --navy: #003366;
    --navy-light: #004080;
    --navy-dark: #002244;
    --metal: #E5E7EB;
    --metal-dark: #C9CDD4;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --status-ingresado: #9CA3AF;
    --status-presupuesto: #F59E0B;
    --status-repuesto: #F97316;
    --status-listo: #22C55E;
    --status-entregado: #3B82F6;
    --danger: #EF4444;
    --sidebar-w: 260px;
    --topbar-h: 64px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.sidebar-brand h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.sidebar-brand span {
    display: block;
    font-size: .7rem;
    color: rgba(255, 255, 255, .5);
    font-weight: 400;
    letter-spacing: .5px;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, .65);
    font-size: .9rem;
    font-weight: 500;
    transition: all .2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .9);
}

.nav-item.active {
    background: rgba(255, 255, 255, .15);
    color: var(--white);
    font-weight: 600;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .7rem;
    color: rgba(255, 255, 255, .3);
    text-align: center;
}

/* ─── Main Content ─── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    border-radius: 10px;
    padding: 8px 16px;
    width: 400px;
    max-width: 50%;
    border: 1px solid transparent;
    transition: all .2s ease;
}

.topbar-search:focus-within {
    border-color: var(--navy);
    background: var(--white);
}

.topbar-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: .9rem;
    font-family: inherit;
    width: 100%;
    color: var(--gray-800);
}

.topbar-search svg {
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    flex-shrink: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}


.page-content {
    padding: 28px 32px;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 4px;
    letter-spacing: -.5px;
}

.page-subtitle {
    font-size: .85rem;
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ─── Cards ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    border: 1px solid var(--gray-200);
    transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
}

.stat-card .stat-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--navy);
    margin-top: 4px;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

/* ─── Semaphore Table ─── */
.table-container {
    background: var(--white);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
}

.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-600);
}

.filter-pill:hover {
    border-color: var(--navy);
    color: var(--navy);
}

.filter-pill.active {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.filter-pill .pill-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 16px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--gray-500);
    background: var(--gray-50);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

tbody td {
    padding: 14px 16px;
    font-size: .85rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

tbody tr {
    transition: background .15s ease;
    cursor: pointer;
}

tbody tr:hover {
    background: var(--gray-50);
}

tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-INGRESADO {
    background: #F3F4F6;
    color: #6B7280;
}

.status-EN_PRESUPUESTO {
    background: #FEF3C7;
    color: #D97706;
}

.status-ESPERANDO_REPUESTO {
    background: #FFEDD5;
    color: #EA580C;
}

.status-LISTO {
    background: #DCFCE7;
    color: #16A34A;
}

.status-ENTREGADO {
    background: #DBEAFE;
    color: #2563EB;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s ease;
    border: none;
}

.btn-primary {
    background: var(--navy);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--navy-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 51, 102, .3);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: var(--status-listo);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 6px 14px;
    font-size: .8rem;
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* ─── Forms ─── */
.form-card {
    background: var(--white);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    border: 1px solid var(--gray-200);
    max-width: 800px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: .9rem;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    background: var(--gray-50);
    color: var(--gray-800);
    transition: all .2s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--navy);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, .1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

select.form-input {
    cursor: pointer;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: .85rem;
    border-bottom: 1px solid var(--gray-100);
    transition: background .15s ease;
}

.autocomplete-item:hover {
    background: var(--gray-50);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item .ac-name {
    font-weight: 600;
    color: var(--gray-800);
}

.autocomplete-item .ac-detail {
    font-size: .75rem;
    color: var(--gray-500);
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .2);
    animation: modalIn .3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    border-radius: 6px;
    transition: all .2s ease;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* ─── Toast ─── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 12px;
    font-size: .85rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    animation: toastIn .3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-success {
    background: #065F46;
    color: #fff;
}

.toast-error {
    background: #991B1B;
    color: #fff;
}

.toast-info {
    background: var(--navy);
    color: #fff;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: .5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: .85rem;
}

/* ─── Setup Screen ─── */
.setup-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px;
}

.setup-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .1);
}

.setup-card h1 {
    font-size: 2rem;
    font-weight: 900;
    color: var(--navy);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.setup-card .setup-subtitle {
    color: var(--gray-500);
    font-size: .9rem;
    margin-bottom: 32px;
}

.setup-step {
    text-align: left;
    margin-bottom: 20px;
}

.setup-step h3 {
    font-size: .9rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setup-step .step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--navy);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 800;
    flex-shrink: 0;
}

/* ─── Client History ─── */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding: 14px 18px;
    border-radius: 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    transition: all .2s ease;
}

.history-item:hover {
    border-color: var(--navy);
}

.history-item .hi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.history-item .hi-id {
    font-weight: 700;
    color: var(--navy);
    font-size: .85rem;
}

.history-item .hi-date {
    font-size: .75rem;
    color: var(--gray-500);
}

.history-item .hi-detail {
    font-size: .85rem;
    color: var(--gray-600);
}

/* ─── Status Select ─── */
.status-select {
    padding: 5px 10px;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    outline: none;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-search {
        width: 100%;
        max-width: none;
    }

    .page-content {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}