@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Unique Soft Palette */
    --bg-base: #f9f9fb;
    --bg-surface: #ffffff;

    --primary-soft: #818cf8;
    /* Soft Indigo */
    --primary-deep: #4f46e5;

    --text-dark: #1e1b4b;
    --text-p: #6b7280;

    /* Soft Status Colors */
    --badge-received-bg: #e2e8f0;
    --badge-received-text: #475569;

    --badge-process-bg: #fef08a;
    /* Soft Yellow */
    --badge-process-text: #854d0e;

    --badge-ok-bg: #bbf7d0;
    /* Soft Green */
    --badge-ok-text: #166534;

    --badge-no-bg: #fecaca;
    /* Soft Red */
    --badge-no-text: #991b1b;

    --badge-delivered-bg: #bfdbfe;
    /* Soft Blue */
    --badge-delivered-text: #1e3a8a;

    --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.05);
    --card-radius: 28px;
    --btn-radius: 16px;
    --input-radius: 14px;

    --font-main: 'Outfit', sans-serif;
    --transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --border-color: rgba(0, 0, 0, 0.07);
}

/* ================================================
   DARK MODE — all color overrides via data-theme
   ================================================ */
[data-theme="dark"] {
    --bg-base: #0f0f13;
    --bg-surface: #1a1a24;

    --primary-soft: #818cf8;
    --primary-deep: #6366f1;

    --text-dark: #e2e2f0;
    --text-p: #8b8fa8;
    --border-color: rgba(255, 255, 255, 0.07);

    /* Status badge colors — muted for dark */
    --badge-received-bg: #1e2330;
    --badge-received-text: #94a3b8;

    --badge-process-bg: #2d2200;
    --badge-process-text: #fcd34d;

    --badge-ok-bg: #052e16;
    --badge-ok-text: #4ade80;

    --badge-no-bg: #2c0f0f;
    --badge-no-text: #f87171;

    --badge-delivered-bg: #0c1a3a;
    --badge-delivered-text: #93c5fd;

    --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.4);
}

/* Dark body background */
[data-theme="dark"] body {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.06), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(129, 140, 248, 0.06), transparent 25%);
}

/* Dark surfaces */
[data-theme="dark"] .surface-panel {
    background: var(--bg-surface);
    border-color: rgba(255, 255, 255, 0.06);
}

/* Dark inputs and selects */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #16161e;
    color: var(--text-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    background: #1e1e2e;
    border-color: var(--primary-soft);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #4b5068;
}

/* Dark table rows */
[data-theme="dark"] td {
    background: #16161e;
}

[data-theme="dark"] tr {
    background: #1a1a24;
}

/* Dark modal */
[data-theme="dark"] .modal-content {
    background: #1a1a24;
}

[data-theme="dark"] .close-modal {
    background: #16161e;
    color: var(--text-dark);
}

[data-theme="dark"] .close-modal:hover {
    background: #252535;
}

/* Dark quick-sheet */
[data-theme="dark"] .quick-sheet {
    background: #1a1a24;
}

[data-theme="dark"] .quick-sheet-handle {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .quick-field input,
[data-theme="dark"] .quick-field select,
[data-theme="dark"] .quick-field textarea {
    background: #16161e;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-dark);
}

[data-theme="dark"] .quick-field input:focus,
[data-theme="dark"] .quick-field select:focus,
[data-theme="dark"] .quick-field textarea:focus {
    background: #1e1e2e;
    border-color: var(--primary-soft);
}

/* Dark stat cards */
[data-theme="dark"] .sc-process {
    background: var(--badge-process-bg);
    color: var(--badge-process-text);
}

[data-theme="dark"] .sc-ok {
    background: var(--badge-ok-bg);
    color: var(--badge-ok-text);
}

[data-theme="dark"] .sc-no {
    background: var(--badge-no-bg);
    color: var(--badge-no-text);
}

[data-theme="dark"] .sc-delivered {
    background: var(--badge-delivered-bg);
    color: var(--badge-delivered-text);
}

/* Dark search bar */
[data-theme="dark"] .search-bar {
    background: #1a1a24;
}

/* Dark secondary buttons */
[data-theme="dark"] .secondary-btn {
    background: #1a1a24;
    color: var(--text-dark);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .secondary-btn:hover {
    background: #252535;
}

/* Dark action buttons */
[data-theme="dark"] .action-btn {
    color: var(--text-p);
}

/* Users table dark */
[data-theme="dark"] #users-table tr {
    background: #1a1a24;
}

/* Dark login */
[data-theme="dark"] .login-container {
    background: #1a1a24;
}

/* Dark widget */
[data-theme="dark"] .widget,
[data-theme="dark"] .list-container,
[data-theme="dark"] .form-container {
    background: var(--bg-surface);
}

/* Dark modal body inputs */
[data-theme="dark"] #modal-body input,
[data-theme="dark"] #modal-body textarea {
    background: #16161e;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-dark);
}

/* Labels in dark */
[data-theme="dark"] label {
    color: var(--text-dark);
}




* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    /* Soft glowing orbs in background to make it unique */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(129, 140, 248, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(167, 139, 250, 0.08), transparent 25%);
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

p {
    font-weight: 300;
    line-height: 1.6;
}

/* Views Management */
.view {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.view.active-view {
    display: flex;
}

.content-section {
    display: none;
    animation: scaleFadeIn 0.5s var(--transition) forwards;
    transform-origin: top center;
}

.content-section.active-section {
    display: block;
}

@keyframes scaleFadeIn {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Premium Surface panels */
.surface-panel {
    background: var(--bg-surface);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Login View */
#login-view {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    padding: 50px 40px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.logo-container i {
    width: 48px;
    height: 48px;
    color: var(--primary-deep);
    background: rgba(129, 140, 248, 0.1);
    padding: 10px;
    border-radius: 16px;
}

.roles-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 32px;
}

.role-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    border: 2px solid transparent;
    border-radius: var(--btn-radius);
    background: var(--bg-base);
    font-size: 16px;
    font-weight: 500;
    color: var(--text-dark);
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition);
}

.role-btn:hover {
    background: white;
    border-color: var(--primary-soft);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(129, 140, 248, 0.1);
    color: var(--primary-deep);
}

/* Main Layout */
#main-layout {
    width: 100%;
    align-items: flex-start;
}

/* ─── Sidebar desktop ─────────────────────────────────────── */
.sidebar {
    width: 260px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    background: #111111;
    border-radius: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    border: none;
    flex-shrink: 0;
}

/* Top bar (always visible on desktop & mobile) */
.sidebar-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 20px;
    background: #111111;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.sidebar-logo i {
    width: 28px;
    height: 28px;
    color: var(--primary-soft);
}

.sidebar-logo h2 {
    font-size: 20px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.01em;
}

.sidebar-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Hamburger button — hidden on desktop */
.menu-toggle-btn {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.menu-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.menu-toggle-btn i {
    width: 22px;
    height: 22px;
}

/* User info compact (top bar, mobile only) */
.user-info-compact {
    display: none;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 14px;
    font-weight: 500;
}

.user-info-compact .avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

/* Nav menu — always expanded on desktop */
.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 16px 20px;
    overflow: hidden;
    background: #111111;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.nav-btn i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-btn:hover,
.nav-btn.active {
    background: var(--primary-deep);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* User info at bottom of desktop sidebar */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info-desktop {
    display: flex;
    /* shown on desktop */
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.user-details span {
    font-size: 14px;
    font-weight: 600;
    color: white;
    padding-bottom: 2px;
}

.user-details .badge {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

#logout-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    transition: var(--transition);
    padding: 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

#logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.nav-links {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--btn-radius);
    color: var(--text-p);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.nav-btn i {
    width: 20px;
    height: 20px;
}

.nav-btn:hover,
.nav-btn.active {
    background: var(--primary-deep);
    color: white;
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.2);
}



/* Content Area */
.content-area {
    flex: 1;
    padding: 20px 40px;
    max-width: 1400px;
    width: 100%;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 40px;
    padding-top: 10px;
}

.section-header h2 {
    font-size: 28px;
}

.date-header {
    color: var(--text-p);
    font-size: 15px;
    font-weight: 400;
}

/* Dashboard Stats - Unique floating pill design */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    flex: 1;
    min-width: 200px;
    padding: 24px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    border-radius: 100px;
    /* Pill shape */
}

.stat-card:hover {
    transform: translateY(-5px);
}

/* Color overrides for stat text to be soft */
.sc-process {
    background: var(--badge-process-bg);
    color: var(--badge-process-text);
}

.sc-ok {
    background: var(--badge-ok-bg);
    color: var(--badge-ok-text);
}

.sc-no {
    background: var(--badge-no-bg);
    color: var(--badge-no-text);
}

.sc-delivered {
    background: var(--badge-delivered-bg);
    color: var(--badge-delivered-text);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-details h3 {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 2px;
}

.stat-details p {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.dashboard-widgets {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.widget {
    padding: 32px;
}

.widget h3 {
    margin-bottom: 24px;
    font-size: 20px;
}

/* Soft Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
    /* Spaced out rows */
}

th {
    text-align: left;
    padding: 0 20px 10px;
    color: var(--text-p);
    font-weight: 500;
    font-size: 14px;
    border: none;
}

td {
    padding: 20px;
    background: var(--bg-base);
    vertical-align: middle;
}

/* Left and right rounded corners for table rows */
tr td:first-child {
    border-radius: 16px 0 0 16px;
}

tr td:last-child {
    border-radius: 0 16px 16px 0;
}

.status-badge {
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
}

.status-En.Proceso {
    background: var(--badge-process-bg);
    color: var(--badge-process-text);
}

.status-OK {
    background: var(--badge-ok-bg);
    color: var(--badge-ok-text);
}

.status-Recibido {
    background: var(--badge-received-bg);
    color: var(--badge-received-text);
}

.status-NO {
    background: var(--badge-no-bg);
    color: var(--badge-no-text);
}

.status-Entregado {
    background: var(--badge-delivered-bg);
    color: var(--badge-delivered-text);
}

/* Forms */
.form-container {
    padding: 40px;
}

.form-row {
    display: flex;
    gap: 30px;
    margin-bottom: 24px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group.full-width {
    flex: 100%;
}

label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
    margin-left: 4px;
}

input,
select,
textarea {
    padding: 16px 20px;
    border: 2px solid transparent;
    border-radius: var(--input-radius);
    background: var(--bg-base);
    font-family: var(--font-main);
    font-size: 15px;
    color: var(--text-dark);
    transition: var(--transition);
}

input::placeholder,
textarea::placeholder {
    color: #a1a1aa;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    background: white;
    border-color: var(--primary-soft);
    box-shadow: 0 8px 20px rgba(129, 140, 248, 0.1);
}

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: var(--input-radius);
    padding: 50px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-base);
}

.upload-area:hover {
    border-color: var(--primary-soft);
    background: rgba(129, 140, 248, 0.05);
}

.upload-area i {
    color: var(--primary-soft);
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
}

.photo-preview-container {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.photo-preview {
    width: 90px;
    height: 90px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 40px;
}

.primary-btn {
    background: var(--primary-deep);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--btn-radius);
    font-weight: 500;
    font-size: 16px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(79, 70, 229, 0.35);
}

.secondary-btn {
    background: var(--bg-base);
    color: var(--text-dark);
    border: none;
    padding: 16px 32px;
    border-radius: var(--btn-radius);
    font-weight: 500;
    font-size: 16px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: #e2e8f0;
}

.search-bar {
    display: flex;
    align-items: center;
    background: white;
    padding: 5px 20px;
    border-radius: 100px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
    width: 350px;
}

.search-bar i {
    color: var(--text-p);
    margin-right: 10px;
}

.search-bar input {
    border: none;
    background: none;
    padding: 10px 0;
    border-radius: 0;
    box-shadow: none;
    flex: 1;
}

.search-bar input:focus {
    border: none;
    box-shadow: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(30, 27, 75, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    padding: 40px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 32px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.close-modal {
    background: var(--bg-base);
    border: none;
    cursor: pointer;
    color: var(--text-dark);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-modal:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

.modal-footer {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

#modal-body input,
#modal-body textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    background: white;
    font-family: 'Outfit', sans-serif;
    color: var(--text-dark);
    margin-bottom: 5px;
}

#modal-body input:focus,
#modal-body textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Customer View */
#customer-view {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.customer-container {
    max-width: 550px;
    width: 100%;
    padding: 50px 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.customer-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    color: var(--primary-deep);
}

.customer-header i {
    width: 64px;
    height: 64px;
    background: rgba(79, 70, 229, 0.1);
    padding: 14px;
    border-radius: 20px;
}

.tracking-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    justify-content: center;
}

.tracking-result.hidden {
    display: none;
}

.tracking-result {
    width: 100%;
    text-align: center;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-p);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 15px;
    margin-top: 20px;
    padding: 10px;
    transition: var(--transition);
}

.text-btn:hover {
    color: var(--text-dark);
}

/* Global Buttons for tables */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-p);
    transition: var(--transition);
    margin-right: 12px;
    padding: 8px;
    border-radius: 10px;
}

.action-btn:hover {
    color: var(--primary-deep);
    background: rgba(79, 70, 229, 0.1);
}

.delete-btn {
    color: #ef4444;
}

.delete-btn:hover {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.1);
}

/* ========= MOBILE RESPONSIVENESS ========= */
@media(max-width: 900px) {
    #main-layout {
        flex-direction: column;
        align-items: stretch;
    }

    /* ── Sidebar becomes a fixed black top bar ── */
    .sidebar {
        width: 100%;
        min-height: unset;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 50;
        flex-direction: column;
        border-radius: 0;
        margin: 0;
        padding: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
        /* Needed so nav-menu position:absolute is relative to the sidebar */
        overflow: visible;
    }

    /* Top bar always visible */
    .sidebar-topbar {
        padding: 14px 18px;
    }

    /* Show hamburger & compact user info on mobile */
    .menu-toggle-btn {
        display: flex;
    }

    .user-info-compact {
        display: flex;
    }

    /* Desktop logout button hidden (it's also in topbar now) */
    /* We keep the one in topbar */

    /* ── Dropdown menu: absolutely positioned so it never takes layout space ── */
    .nav-menu {
        position: absolute;
        top: 100%;
        /* right below the topbar */
        left: 0;
        right: 0;
        z-index: 49;
        background: #111111;
        padding: 0 16px;
        /* GPU-only transitions — no layout recalc */
        transform: translateY(-6px);
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
            opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
            visibility 0s linear 0.28s;
        will-change: transform, opacity;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    }

    .nav-menu.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
        padding: 10px 16px 16px;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
            opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
            visibility 0s linear 0s;
    }

    /* Hide desktop user-info inside the dropdown on mobile */
    .user-info-desktop {
        display: none;
    }

    /* Nav links stacked vertically inside dropdown */
    .nav-links {
        flex-direction: column;
        gap: 4px;
    }

    .nav-btn {
        font-size: 15px;
        padding: 13px 16px;
    }

    /* Content area */
    .content-area {
        padding: 20px 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .section-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        text-align: center;
        width: 100%;
        margin-bottom: 30px;
    }

    .search-bar {
        width: 100%;
        max-width: 400px;
        justify-content: center;
    }

    .dashboard-widgets {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .widget,
    .stat-card,
    .form-container,
    .list-container {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
    }

    .form-row {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }

    .form-group {
        width: 100%;
        align-items: center;
    }

    input,
    select,
    textarea {
        width: 100%;
    }

    .form-actions {
        justify-content: center;
        flex-direction: column-reverse;
        width: 100%;
    }

    .form-actions button {
        width: 100%;
        justify-content: center;
    }

    /* Tables on Mobile */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        padding: 20px;
        background: var(--bg-surface);
        margin-bottom: 15px;
        border-radius: 20px;
        border: 1px solid rgba(0, 0, 0, 0.05);
    }

    td {
        border: none;
        padding: 10px;
        position: relative;
        padding-left: 50%;
        text-align: right;
        background: none;
        border-radius: 0 !important;
    }

    td:before {
        position: absolute;
        top: 12px;
        left: 15px;
        width: 40%;
        white-space: nowrap;
        text-align: left;
        font-weight: 500;
        color: var(--text-p);
        font-size: 14px;
    }

    td:nth-of-type(1):before {
        content: "ID / Fecha";
    }

    td:nth-of-type(2):before {
        content: "Dispositivo";
    }

    td:nth-of-type(3):before {
        content: "Cliente";
    }

    td:nth-of-type(4):before {
        content: "Estado";
    }

    td:nth-of-type(5):before {
        content: "Técnico";
    }

    td:nth-of-type(6):before {
        content: "Acciones";
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
        justify-content: center;
    }
}

/* User Management Specific */
#users-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

#users-table tr {
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

#users-table td,
#users-table th {
    padding: 16px;
    text-align: left;
}

#users-table thead th {
    font-size: 13px;
    color: var(--text-p);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 20px;
}

/* ---- Mobile overrides for users table ---- */
@media(max-width: 900px) {

    /* Reset the generic table-to-card transforms for users table */
    #users-table,
    #users-table thead,
    #users-table tbody,
    #users-table th,
    #users-table td,
    #users-table tr {
        display: block;
    }

    /* Hide the column headers gracefully */
    #users-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Each user row = a clean card */
    #users-table tr {
        background: var(--bg-surface);
        border-radius: 20px;
        border: 1px solid rgba(0, 0, 0, 0.04);
        margin-bottom: 14px;
        padding: 16px 20px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    }

    /* Reset the generic td padding-left and label overrides */
    #users-table td {
        padding: 8px 0;
        padding-left: 0 !important;
        text-align: left !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    }

    #users-table td:last-child {
        border-bottom: none;
        padding-top: 12px;
    }

    /* Override the generic :before labels with correct ones */
    #users-table td:before {
        position: static !important;
        width: auto !important;
        font-weight: 600 !important;
        font-size: 13px !important;
        color: var(--text-p) !important;
        text-align: left !important;
        white-space: nowrap;
        margin-right: 10px;
    }

    #users-table td:nth-of-type(1):before {
        content: "👤 Usuario";
    }

    #users-table td:nth-of-type(2):before {
        content: "🏷️ Rol";
    }

    #users-table td:nth-of-type(3):before {
        content: "🏪 Sucursal";
    }

    #users-table td:nth-of-type(4):before {
        content: "⚙️ Acciones";
    }
}

.badge-role {
    background: var(--bg-base);
    color: var(--text-p);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

/* Login Form Security */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 320px;
    margin: 20px auto 0;
}

.login-form .form-group {
    text-align: left;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
    width: 100%;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ================================================
   FAB — Floating Action Button
   ================================================ */
.fab-btn {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: 200;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-soft), var(--primary-deep));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.25s ease;
    /* Hidden by default — shown only inside main-layout */
    opacity: 0;
    pointer-events: none;
}

/* Show FAB when main layout is active */
#main-layout.active-view~.fab-btn,
body:has(#main-layout.active-view) .fab-btn {
    opacity: 1;
    pointer-events: auto;
}

.fab-btn i {
    width: 28px;
    height: 28px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.55);
}

.fab-btn:active {
    transform: scale(0.95);
}

.fab-btn.is-open i {
    transform: rotate(45deg);
}

/* Pulse ring */
.fab-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(129, 140, 248, 0.4);
    animation: fab-pulse 2.5s ease-out infinite;
}

@keyframes fab-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(1.35);
        opacity: 0;
    }

    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

/* ================================================
   Quick-add overlay + slide-up sheet
   ================================================ */
.quick-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 10, 40, 0.5);
    backdrop-filter: blur(6px);
    z-index: 201;
    transition: opacity 0.3s ease;
}

.quick-overlay.hidden {
    display: none;
}

.quick-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 202;
    background: white;
    border-radius: 28px 28px 0 0;
    padding: 12px 24px 32px;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 92vh;
    overflow-y: auto;
}

.quick-sheet.open {
    transform: translateY(0);
}

/* Drag handle */
.quick-sheet-handle {
    width: 44px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin: 0 auto 20px;
}

.quick-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
}

.quick-sheet-header h3 {
    font-size: 20px;
    color: var(--text-dark);
}

/* Fields */
.quick-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 16px;
}

.quick-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-p);
    margin-left: 2px;
}

.quick-field input,
.quick-field select,
.quick-field textarea {
    padding: 13px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    background: var(--bg-base);
    font-family: var(--font-main);
    font-size: 15px;
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.quick-field input:focus,
.quick-field select:focus,
.quick-field textarea:focus {
    outline: none;
    background: white;
    border-color: var(--primary-soft);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.12);
}

.quick-field textarea {
    resize: none;
    line-height: 1.5;
}

.quick-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 480px) {
    .quick-field-row {
        grid-template-columns: 1fr;
    }
}

/* Submit actions */
.quick-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.quick-submit-btn {
    flex: 1;
    justify-content: center;
    padding: 15px 20px;
    font-size: 16px;
    border-radius: 16px;
}

.quick-actions .secondary-btn {
    padding: 15px 20px;
    border-radius: 16px;
    border: 1.5px solid #e2e8f0;
}

/* Success flash on submit */
@keyframes flash-green {
    0% {
        background: #10b981;
        box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
    }

    100% {
        background: var(--primary-deep);
        box-shadow: 0 8px 16px rgba(79, 70, 229, 0.25);
    }
}