/* =========================================
   EquipTrack SaaS UI — Global Stylesheet
   ========================================= */

/* --- BASE --- */
body {
    font-family: 'Inter', sans-serif !important;
    background-color: #f8fafc !important;
    color: #334155;
}

/* Only lock scrolling in the authenticated app shell */
body.app-auth {
    overflow: hidden;
}

/* =========================================
   MOBILE COMPACT MODE (authenticated app)
   ========================================= */
@media (max-width: 767.98px) {
    body.app-auth {
        font-size: 14.5px;
    }

    /* Buttons */
    .btn {
        padding: 0.5rem 1rem !important;
        border-radius: 10px !important;
    }
    .btn-sm {
        padding: 0.35rem 0.7rem !important;
    }

    /* Cards */
    .card {
        border-radius: 14px !important;
    }
    .card-header {
        border-top-left-radius: 14px !important;
        border-top-right-radius: 14px !important;
    }

    /* Forms */
    .form-control, .form-select {
        padding: 0.6rem 0.85rem !important;
        border-radius: 10px !important;
    }

    /* Tables */
    .table th {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.7rem;
    }
    .table td {
        padding: 0.65rem 0.75rem !important;
    }

    /* Sidebar nav items */
    .nav-link {
        padding: 0.6rem 0.85rem !important;
    }

    /* Make common headings slightly smaller */
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.2rem; }
    h4 { font-size: 1.1rem; }

    /* Mobile: compact action layout in tab headers (ex: Inventory) */
    .ui-mobile-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .ui-mobile-actions__secondary {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        white-space: nowrap;
    }
    .ui-mobile-actions__primary {
        flex: 1 1 100%;
        justify-content: center;
        white-space: nowrap;
    }
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- CARD --- */
.card {
    border: 1px solid transparent !important;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.03), 0 2px 4px -1px rgba(0,0,0,0.03) !important;
    border-radius: 16px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-header {
    background-color: #fff !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-top-left-radius: 16px !important;
    border-top-right-radius: 16px !important;
}

/* --- HOVER STATES (cards, list surfaces, table rows) --- */
@media (hover: hover) and (pointer: fine) {
    /* Only inner cards get hover effect when nested inside a larger card */
    .card .card:not(.auth-card),
    .ui-dashboard-card {
        will-change: transform, box-shadow;
    }
    .card .card:not(.auth-card):hover,
    .ui-dashboard-card:hover {
        transform: translateY(-2px);
        border-color: var(--ui-theme-border) !important;
        box-shadow:
            0 14px 30px rgba(15, 23, 42, 0.08),
            0 0 0 1px var(--ui-theme-border) !important;
    }

    /* Common list-like white surfaces used across tabs */
    div.border.rounded-4.bg-white,
    div.border.border-light-subtle.rounded-4.bg-white,
    div.shadow-sm.rounded-4.bg-white,
    div.shadow-sm.rounded-3.bg-white {
        transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
        will-change: transform, box-shadow;
    }
    div.border.rounded-4.bg-white:hover,
    div.border.border-light-subtle.rounded-4.bg-white:hover,
    div.shadow-sm.rounded-4.bg-white:hover,
    div.shadow-sm.rounded-3.bg-white:hover {
        transform: translateY(-2px);
        box-shadow:
            0 12px 24px rgba(15, 23, 42, 0.08),
            0 0 0 1px var(--ui-theme-border) !important;
        border-color: var(--ui-theme-border) !important;
    }

    .table-hover tbody tr {
        transition: background-color 0.18s ease, box-shadow 0.18s ease;
    }
    .table-hover tbody tr:hover {
        background-color: #f8fbff !important;
        box-shadow: inset 0 0 0 999px rgba(13, 110, 253, 0.03);
    }

    .dropdown-item,
    .list-group-item {
        transition: transform 0.16s ease, background-color 0.16s ease;
    }
    .dropdown-item:hover,
    .list-group-item:hover {
        transform: translateX(1px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .card,
    .table-hover tbody tr,
    .dropdown-item,
    .list-group-item,
    div.border.rounded-4.bg-white,
    div.border.border-light-subtle.rounded-4.bg-white,
    div.shadow-sm.rounded-4.bg-white,
    div.shadow-sm.rounded-3.bg-white {
        transition: none !important;
        transform: none !important;
    }
}

/* Theme-driven hover border color */
:root {
    --ui-theme-border: #0d6efd;
}
body[data-theme="blue"] { --ui-theme-border: #0d6efd; }
body[data-theme="emerald"] { --ui-theme-border: #198754; }
body[data-theme="indigo"] { --ui-theme-border: #0dcaf0; }
body[data-theme="rose"] { --ui-theme-border: #dc3545; }
body[data-theme="orange"] { --ui-theme-border: #ffc107; }
body[data-theme="purple"] { --ui-theme-border: #8b5cf6; }

/* --- BUTTONS --- */
.btn {
    border-radius: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.2px;
    padding: 0.6rem 1.25rem !important;
    transition: all 0.2s ease !important;
}
.btn:disabled,
.btn.disabled {
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.65;
}

/* Avoid "jumping" for icon/link/close buttons */
.btn:not(.btn-link):not(.btn-close):not(.rounded-circle):not(.p-0):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Keyboard accessibility */
.btn:focus-visible,
.dropdown-item:focus-visible,
[role="button"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(148,163,184,0.22) !important;
}

/* Loading state (JS can toggle .is-loading) */
.btn.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}
.btn.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: btnSpin 0.7s linear infinite;
}
.btn.is-loading > * {
    opacity: 0;
}
.btn-sm.is-loading::after { width: 0.9rem; height: 0.9rem; }

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}
.btn-sm { padding: 0.4rem 0.8rem !important; }

/* =========================================
   UI TOKENS — Buttons & Badges
   (small composable classes)
   ========================================= */
:root{
    --ui-radius: 12px;
    --ui-hover-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
    --ui-hover-shadow-soft: 0 8px 18px rgba(15, 23, 42, 0.08);
    --ui-hover-translate: -1px;
}

/* Button sizes */
.ui-btn-sm { padding: 0.4rem 0.8rem !important; border-radius: 10px !important; }
.ui-btn-md { padding: 0.6rem 1.25rem !important; border-radius: 12px !important; }
.ui-btn-lg { padding: 0.8rem 1.25rem !important; border-radius: 14px !important; }

/* Hover effects: opt-in for lift (avoid global "jump") */
.ui-hover-lift { will-change: transform, box-shadow; }
.ui-hover-lift:hover { transform: translateY(var(--ui-hover-translate)); box-shadow: var(--ui-hover-shadow); }
.ui-hover-soft:hover { transform: translateY(var(--ui-hover-translate)); box-shadow: var(--ui-hover-shadow-soft); }

/* Icon-only buttons (square/circle) */
.ui-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 999px !important;
}
.ui-btn-icon.ui-btn-sm { width: 34px; height: 34px; }
.ui-btn-icon .lucide { width: 18px; height: 18px; }

/* Ghost buttons (no border/background until hover) */
.ui-btn-ghost {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}
.ui-btn-ghost:hover {
    transform: none !important;
    box-shadow: none !important;
    background: rgba(2, 6, 23, 0.06) !important;
}
.ui-btn-ghost:active { background: rgba(2, 6, 23, 0.10) !important; }

/* Soft/destructive helpers */
.ui-btn-soft-danger {
    background: rgba(220, 53, 69, 0.10) !important;
    border-color: rgba(220, 53, 69, 0.18) !important;
    color: #dc3545 !important;
}
.ui-btn-soft-danger:hover {
    background: rgba(220, 53, 69, 0.14) !important;
    transform: translateY(var(--ui-hover-translate));
    box-shadow: var(--ui-hover-shadow-soft);
}

.ui-btn-soft-secondary {
    background: rgba(100, 116, 139, 0.10) !important;
    border-color: rgba(100, 116, 139, 0.18) !important;
    color: #475569 !important;
}
.ui-btn-soft-secondary:hover {
    background: rgba(100, 116, 139, 0.14) !important;
    transform: translateY(var(--ui-hover-translate));
    box-shadow: var(--ui-hover-shadow-soft);
}

/* Badges */
.ui-badge {
    border-radius: 999px !important;
    padding: 0.35rem 0.6rem !important;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.ui-badge-outline {
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    color: #64748b !important;
}
.ui-badge-soft-danger {
    background: rgba(220, 53, 69, 0.10) !important;
    border: 1px solid rgba(220, 53, 69, 0.18) !important;
    color: #dc3545 !important;
}
.ui-badge-soft-success {
    background: rgba(25, 135, 84, 0.12) !important;
    border: 1px solid rgba(25, 135, 84, 0.18) !important;
    color: #198754 !important;
}
.ui-badge-soft-warning {
    background: rgba(255, 193, 7, 0.20) !important;
    border: 1px solid rgba(255, 193, 7, 0.26) !important;
    color: #8a6a00 !important;
}

/* --- TABLES --- */
.table th {
    background-color: #f8fafc !important;
    color: #64748b !important;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 1rem !important;
}
.table td {
    padding: 1rem !important;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}

/* --- FORMS --- */
.form-control, .form-select {
    border-radius: 10px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0.75rem 1rem !important;
    box-shadow: none !important;
    transition: all 0.2s;
}
.form-control:focus, .form-select:focus {
    border-color: #94a3b8 !important;
    box-shadow: 0 0 0 4px rgba(148,163,184,0.15) !important;
}
.form-control::placeholder { color: #94a3b8; font-weight: 400; }

/* --- SIDEBAR --- */
.sidebar-bg {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%) !important;
    transition: width 0.3s ease;
}
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1035;
}

/* Mobile: sidebar becomes off-canvas */
@media (max-width: 767.98px) {
    .sidebar-bg {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: 260px !important;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        z-index: 1040;
        box-shadow: 8px 0 30px rgba(0,0,0,0.18);
    }
    .sidebar-bg.is-open {
        transform: translateX(0);
    }
}
.nav-link {
    color: #94a3b8 !important;
    border-radius: 10px !important;
    margin-bottom: 4px;
    font-weight: 500;
    cursor: pointer;
    padding: 0.75rem 1rem !important;
}
.nav-link:hover { background-color: rgba(255,255,255,0.05); color: #fff !important; }
.nav-link.active { color: #fff !important; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* --- MODALS --- */
.modal-content {
    border-radius: 20px !important;
    border: none !important;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25) !important;
}
.modal-backdrop.show { opacity: 0.6; backdrop-filter: blur(4px); }

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.75rem !important;
    }
    .modal-header.px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .modal-body.p-4 { padding: 1rem !important; }
}

/* Small screen: DO form rows wrap instead of overflow */
@media (max-width: 575.98px) {
    .do-item-row {
        flex-wrap: wrap;
        gap: 0.5rem !important;
        align-items: stretch !important;
    }
    .do-item-row .vr {
        display: none !important;
    }
    .do-item-row .inv-select {
        flex: 1 1 100%;
        width: 100% !important;
    }
    .do-item-row .qty-input {
        flex: 1 1 auto;
        width: 100% !important;
        text-align: left !important;
    }
}

/* Toasts: fit mobile width */
@media (max-width: 575.98px) {
    #toast-container {
        top: 12px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
    }
    #toast-container .alert {
        min-width: 0 !important;
        width: 100% !important;
    }
}

/* --- ICONS --- */
.lucide { width: 20px; height: 20px; stroke-width: 2; }

/* --- HEADER (mobile tweaks) --- */
@media (max-width: 767.98px) {
    .app-header {
        height: 60px !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    .app-header .btn.rounded-circle {
        padding: 0.4rem !important;
    }
    .app-header .btn.rounded-circle .lucide {
        width: 18px;
        height: 18px;
    }
    .app-header .vr {
        margin-left: 0.5rem !important;
        margin-right: 0.5rem !important;
    }
    .app-header [data-action="toggle-account-menu"] {
        padding-right: 0.5rem !important;
    }
    .app-header [data-action="toggle-account-menu"] > div.rounded-circle {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
}

/* --- THEMES --- */
.theme-blue-bg    { background-color: #0d6efd !important; color: white !important; }
.theme-blue-text  { color: #0d6efd !important; }
.theme-emerald-bg   { background-color: #198754 !important; color: white !important; }
.theme-emerald-text { color: #198754 !important; }
.theme-indigo-bg   { background-color: #0dcaf0 !important; color: white !important; }
.theme-indigo-text { color: #0dcaf0 !important; }
.theme-rose-bg   { background-color: #dc3545 !important; color: white !important; }
.theme-rose-text { color: #dc3545 !important; }
.theme-orange-bg   { background-color: #ffc107 !important; color: black !important; }
.theme-orange-text { color: #ffc107 !important; }

.theme-purple-bg   { background-color: #8b5cf6 !important; color: white !important; }
.theme-purple-text { color: #8b5cf6 !important; }

/* =========================================
   AUTH / LOGIN
   ========================================= */
.auth-bg{
    min-height: 100vh;
    background: radial-gradient(1200px 700px at 70% 35%, #f1f5f9 0%, #f8fafc 65%);
}
.auth-card{
    max-width: 1120px;
    border-radius: 22px !important;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.12) !important;
}
.auth-left{
    background: linear-gradient(135deg, #0d6efd 0%, #0f172a 55%, #1e293b 100%);
    position: relative;
}
.auth-left::before{
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(800px 500px at 35% 25%, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 60%);
    pointer-events: none;
}
.auth-left > *{ position: relative; }
.auth-left-sub{
    font-size: 0.9rem;
    opacity: 0.85;
}
.auth-logo-badge{
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.18);
    font-size: 18px;
}
.auth-feature{
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 14px;
    padding: 12px 14px;
    backdrop-filter: blur(6px);
}
.auth-feature-icon{
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: rgba(255,255,255,0.16);
    color: #ffffff;
    flex: 0 0 auto;
}
.auth-icon{
    display: inline-block;
    color: #ffffff;
}
.auth-lang{
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}
.auth-lang-label{
    font-size: 0.78rem;
}
.auth-lang-select{
    width: 104px;
    font-size: 0.78rem;
}
.auth-login-btn{
    border-radius: 12px !important;
    padding: 0.55rem 1rem !important;
}
.auth-input{
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
    height: 38px;
}
.auth-toggle-btn{
    width: 38px;
    height: 38px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px !important;
}
.auth-demo{
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
}
