/* ============================================================
   CloudSchool Inventory — Modern UI Theme
   ============================================================ */

/* ── Base & Typography ── */
:root {
    --cs-primary: #2563eb;
    --cs-primary-dark: #1d4ed8;
    --cs-primary-light: #dbeafe;
    --cs-success: #059669;
    --cs-danger: #dc2626;
    --cs-warning: #d97706;
    --cs-info: #0891b2;
    --cs-bg: #f1f5f9;
    --cs-sidebar: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --cs-header: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    --cs-card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --cs-card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
    --cs-radius: 0.75rem;
    --cs-transition: all 0.2s ease;
    --cs-z-search-overlay: 1200;
    --cs-z-menu-overlay: 1400;
    --cs-z-toast-overlay: 1600;
    --cs-z-sticky-topbar: 200;
    --cs-z-sticky-footer: 200;
    --cs-z-sticky-tablehead: 10;
    --cs-z-local-overlay: 100;
}

html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--cs-bg);
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
}

body {
    overflow-x: hidden;
    line-height: 1.45;
}

.skip-link {
    position: absolute;
    left: 0.75rem;
    top: -3rem;
    z-index: var(--cs-z-toast-overlay);
    background: #0f172a;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
}

.skip-link:focus-visible {
    top: 0.75rem;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.container-fluid {
    width: 100%;
    max-width: 100%;
}

.page-header {
    gap: 0.75rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Links & Buttons ── */
a { color: var(--cs-primary); text-decoration: none; }
a:hover { color: var(--cs-primary-dark); }

.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--cs-transition);
    border: none;
    padding: 0.5rem 1rem;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--cs-primary); color: #fff; }
.btn-primary:hover { background: var(--cs-primary-dark); color: #fff; }
.btn-success { background: var(--cs-success); }
.btn-danger { background: var(--cs-danger); }
.btn-warning { background: var(--cs-warning); color: #fff; }
.btn-info { background: var(--cs-info); color: #fff; }
.btn-info:hover { background: #0e7490; color: #fff; }

.btn-outline-primary { border: 1px solid var(--cs-primary); color: var(--cs-primary); background: transparent; }
.btn-outline-primary:hover { background: var(--cs-primary); color: #fff; }
.btn-outline-secondary { border: 1px solid #cbd5e1; color: #475569; background: transparent; }
.btn-outline-secondary:hover { background: #f1f5f9; }

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    border-color: var(--cs-primary);
    outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
.dropdown-item:focus-visible,
.list-group-item-action:focus-visible {
    outline: 2px solid var(--cs-primary);
    outline-offset: 2px;
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-card-shadow);
    transition: var(--cs-transition);
    overflow: hidden;
}
/* Item form Custom Accounts: absolute typeaheads must extend past the card (see .gl-accounts-card) */
.card.gl-accounts-card {
    overflow: visible !important;
}
/* Inventory items grid: Actions column dropdown (Items.razor) */
.card.inventory-items-card {
    overflow: visible !important;
}
.inventory-items-card td.inventory-item-actions-open {
    position: relative;
    z-index: 250;
}
.card:hover { box-shadow: var(--cs-card-shadow-hover); }

.card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 0.9rem;
    color: #334155;
    padding: 0.875rem 1.25rem;
}

.card-body { padding: 1.25rem; }

/* ── Tables ── */
.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}
.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}
.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.table-hover tbody tr:hover {
    background: #f8fafc;
}
.table-sm th, .table-sm td { padding: 0.5rem 0.75rem; }

/* ── Badges ── */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 0.375rem;
    letter-spacing: 0.02em;
}
.bg-success { background: #059669 !important; }
.bg-danger { background: #dc2626 !important; }
.bg-warning { background: #d97706 !important; }
.bg-info { background: #0891b2 !important; }
.bg-secondary { background: #64748b !important; }
.bg-primary { background: var(--cs-primary) !important; }

/* ── Forms ── */
.form-control, .form-select {
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: var(--cs-transition);
    background: #fff;
}
.form-control:hover, .form-select:hover {
    border-color: #94a3b8;
}
.form-label {
    font-weight: 500;
    font-size: 0.8125rem;
    color: #475569;
    margin-bottom: 0.375rem;
}
.form-check-input {
    border-radius: 0.25rem;
    border: 1.5px solid #94a3b8;
}
.form-check-input:checked {
    background-color: var(--cs-primary);
    border-color: var(--cs-primary);
}

/* ── Modals ── */
.modal-content {
    border: none;
    border-radius: var(--cs-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
}
.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: none;
}
.modal-header .modal-title {
    font-size: 1rem;
    font-weight: 600;
}
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.modal-dialog { margin: 0.5rem; max-width: calc(100vw - 1rem); }
@media (min-width: 576px) {
    .modal-dialog { margin: 1.75rem auto; max-width: 500px; }
    .modal-dialog.modal-lg { max-width: 800px; }
    .modal-dialog.modal-xl { max-width: 1140px; }
}

/* ── Alerts ── */
.alert {
    border-radius: 0.5rem;
    border: none;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}
.alert-danger { background: #fef2f2; color: #991b1b; border-left: 3px solid #dc2626; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid #d97706; }
.alert-success { background: #f0fdf4; color: #166534; border-left: 3px solid #059669; }
.alert-info { background: #ecfeff; color: #155e75; border-left: 3px solid #0891b2; }

/* ── Dropdown Menus ── */
.dropdown-menu {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12);
    padding: 0.375rem;
    min-width: 10rem;
}

/* Keep action dropdowns above search/typeahead suggestions and avoid clipping */
.dropdown-menu.show {
    z-index: var(--cs-z-menu-overlay) !important;
}

.table-responsive {
    overflow-y: visible;
    position: relative;
}

.card:has(.dropdown-menu.show),
.table-responsive:has(.dropdown-menu.show) {
    overflow: visible !important;
}
.dropdown-item {
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    transition: var(--cs-transition);
}
.dropdown-item:hover { background: #f1f5f9; }
.dropdown-divider { margin: 0.25rem 0; border-color: #e2e8f0; }

/* ── Actions Dropdown Toggle ── */
.btn.dropdown-toggle {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

/* ── Page Headers ── */
h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}
h2 { font-size: 1.25rem; font-weight: 600; color: #1e293b; }
h3 { font-size: 1.125rem; font-weight: 600; }
h5 { font-size: 1rem; }

/* ── Stat Cards (Dashboard) ── */
.stat-card {
    background: #fff;
    border-radius: var(--cs-radius);
    padding: 1.25rem;
    box-shadow: var(--cs-card-shadow);
    transition: var(--cs-transition);
    border-left: 4px solid transparent;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--cs-card-shadow-hover); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: #0f172a; }
.stat-card .stat-label { font-size: 0.8125rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Breadcrumbs ── */
.breadcrumb {
    font-size: 0.8125rem;
    background: none;
    padding: 0;
    margin-bottom: 0.5rem;
}
.breadcrumb-item a { color: var(--cs-primary); }
.breadcrumb-item.active { color: #64748b; }
.breadcrumb-item + .breadcrumb-item::before { color: #cbd5e1; }

/* ── Search Dropdown (Account Selectors) ── */
.list-group {
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}
.list-group-item { font-size: 0.8125rem; border-color: #f1f5f9; }
.list-group-item-action:hover { background: var(--cs-primary-light); color: var(--cs-primary); }

/* Standardize autocomplete/search suggestion overlays below action dropdowns */
.position-absolute.bg-white.border.rounded.shadow-sm,
.position-absolute.bg-white.border.rounded.shadow-sm.w-100,
.list-group.position-absolute,
.list-group.mt-1 {
    z-index: var(--cs-z-search-overlay) !important;
}

.cs-overlay-search {
    z-index: var(--cs-z-search-overlay) !important;
}

.cs-overlay-toast {
    z-index: var(--cs-z-toast-overlay) !important;
}

.cs-z-sticky-topbar {
    z-index: var(--cs-z-sticky-topbar) !important;
}

.cs-z-sticky-footer {
    z-index: var(--cs-z-sticky-footer) !important;
}

.cs-z-sticky-tablehead {
    z-index: var(--cs-z-sticky-tablehead) !important;
}

.cs-z-local-overlay {
    z-index: var(--cs-z-local-overlay) !important;
}

/* ── Fade-in Animation ── */
.fade-in {
    animation: fadeInUp 0.3s ease-out;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ── */
.spinner-border { width: 1.5rem; height: 1.5rem; border-width: 0.2em; }
.spinner-border-sm { width: 1rem; height: 1rem; }

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

/* ── Print Styles ── */
@media print {
    .no-print, nav, header, .sidebar, .btn, .form-control, .form-select { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; }
}

/* ── Responsive ── */
@media (max-width: 575.98px) {
    .container-fluid { padding-left: 0.75rem; padding-right: 0.75rem; }
    .card-body { padding: 0.875rem; }
    h1 { font-size: 1.25rem; }
    .table { font-size: 0.8125rem; }
    .table thead th { font-size: 0.7rem; padding: 0.5rem 0.5rem; }
    .table tbody td { padding: 0.5rem 0.5rem; }
    .btn { font-size: 0.8125rem; padding: 0.4rem 0.75rem; }
}

@media (max-width: 767.98px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .page-header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .page-header-actions .btn {
        min-height: 2.25rem;
    }

    button,
    .btn,
    .form-control,
    .form-select,
    .dropdown-item,
    .list-group-item-action {
        min-height: 2.5rem;
    }

    .alert.d-flex {
        align-items: flex-start !important;
    }

    .btn-group {
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .fade-in {
        animation: none !important;
    }
}

@media (max-width: 991.98px) {
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 720px;
    }

    .table.table-sm {
        min-width: 640px;
    }
}

/* ── Fix Tailwind-style utility classes used in layout ── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-col { flex-direction: column; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.h-screen { height: 100vh; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.min-w-0 { min-width: 0; }
.font-sans { font-family: inherit; }
.text-gray-900 { color: #1e293b; }
.bg-gray-100 { background: var(--cs-bg); }
.bg-gray-50 { background: var(--cs-bg); }

/* Header utilities */
.h-14 { height: 3.5rem; }
.h-16 { height: 4rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.p-3 { padding: 0.75rem; }
.p-6 { padding: 1.5rem; }
.p-2 { padding: 0.5rem; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-50 { z-index: 50; }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1); }
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); }
.fixed { position: fixed; }
.relative { position: relative; }
.absolute { position: absolute; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.inset-y-0 { top: 0; bottom: 0; }
.left-0 { left: 0; }
.top-1 { top: 0.25rem; }
.right-1 { right: 0.25rem; }
.w-64 { width: 16rem; }
.w-full { width: 100%; }
.w-9 { width: 2.25rem; }
.w-8 { width: 2rem; }
.h-9 { height: 2.25rem; }
.h-8 { height: 2rem; }
.h-6 { height: 1.5rem; }
.h-4 { height: 1rem; }
.w-4 { width: 1rem; }
.w-px { width: 1px; }
.max-w-md { max-width: 28rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-full { border-radius: 9999px; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.text-white { color: #fff; }
.text-gray-200 { color: #e2e8f0; }
.text-gray-300 { color: #cbd5e1; }
.text-gray-400 { color: #9ca3af; }
.text-red-300 { color: #fca5a5; }
.bg-gray-600 { background: #475569; }
.bg-gray-700 { background: #334155; }
.bg-gray-800 { background: #1e293b; }
.bg-red-900\/30 { background: rgba(127, 29, 29, 0.3); }
.bg-red-900\/50 { background: rgba(127, 29, 29, 0.5); }
.bg-black\/50 { background: rgba(0, 0, 0, 0.5); }
.ring-2 { box-shadow: 0 0 0 2px; }
.ring-gray-600 { --tw-ring-color: #475569; }
.border-none { border: none; }
.block { display: block; }
.inline-flex { display: inline-flex; }
.hidden { display: none; }
.transform { transform: translateX(0); }
.translate-x-0 { transform: translateX(0); }
.-translate-x-full { transform: translateX(-100%); }
.transition-transform { transition: transform 0.3s ease-in-out; }
.transition-colors { transition: color 0.2s, background-color 0.2s; }
.duration-300 { transition-duration: 0.3s; }
.ease-in-out { transition-timing-function: ease-in-out; }
.cursor-pointer { cursor: pointer; }
.text-left { text-align: left; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.pl-3 { padding-left: 0.75rem; }
.pl-10 { padding-left: 2.5rem; }
.pr-4 { padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }

.focus\:outline-none:focus { outline: none; }
.focus\:ring-2:focus { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3); }
.focus\:bg-gray-500:focus { background: #64748b; }

.placeholder-gray-400::placeholder { color: #9ca3af; }
.hover\:text-white:hover { color: #fff; }
.hover\:bg-gray-600:hover { background: #475569; }
.hover\:underline:hover { text-decoration: underline; }
.hover\:text-yellow-900:hover { color: #78350f; }

/* Responsive */
@media (min-width: 768px) {
    .md\:hidden { display: none; }
    .md\:flex { display: flex; }
    .md\:block { display: block; }
    .md\:relative { position: relative; }
    .md\:translate-x-0 { transform: translateX(0); }
    .md\:h-16 { height: 4rem; }
    .md\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
    .md\:gap-4 { gap: 1rem; }
    .md\:gap-3 { gap: 0.75rem; }
    .md\:text-sm { font-size: 0.875rem; }
    .md\:text-xl { font-size: 1.25rem; }
    .md\:px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
    .md\:p-6 { padding: 1.5rem; }
    .md\:mr-2 { margin-right: 0.5rem; }
}
@media (min-width: 640px) {
    .sm\:inline { display: inline; }
}
@media (min-width: 1024px) {
    .lg\:block { display: block; }
}

/* ── Header gradient ── */
.bg-gradient-to-r { background: var(--cs-header); }
.from-gray-800 { /* handled by var */ }
.to-gray-700 { /* handled by var */ }

/* ── Blazor Error ── */
.blazor-error-boundary {
    background: #dc2626;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 0.5rem;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ── Validation ── */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--cs-success); }
.invalid { outline: 1px solid var(--cs-danger); }
.validation-message { color: var(--cs-danger); font-size: 0.8125rem; }

/* ── Form floating ── */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder { text-align: start; }

/* ── Misc ── */
.content { padding-top: 1.1rem; }
h1:focus { outline: none; }
.darker-border-checkbox.form-check-input { border-color: #929292; }
.text-\[10px\] { font-size: 10px; }
