:root {
    color-scheme: light;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(7, 89, 133, 0.2), transparent 45%),
        radial-gradient(circle at 50% 28%, rgba(250, 204, 21, 0.12), transparent 26%);
    pointer-events: none;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

.page-header-actions > * {
    width: 100%;
}

.table-wrap {
    position: relative;
}

@media (min-width: 640px) {
    .page-header-actions > * {
        width: auto;
    }
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    color: #0f172a;
    outline: none;
    transition: border-color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out;
}

.form-input,
.form-select,
.custom-select-button {
    min-height: 2.75rem;
}

.form-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #075985 50%), linear-gradient(135deg, #075985 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.5rem;
}

.native-select-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #0f172a;
    outline: none;
    transition: border-color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out, background 150ms ease-out;
}

.custom-select-button:hover {
    background: #f8fafc;
}

.custom-select-button:focus {
    border-color: #18A8E0;
    box-shadow: 0 0 0 3px rgba(24, 168, 224, 0.15);
}

.custom-select-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    color: #075985;
    transition: transform 150ms ease-out;
}

.custom-select.is-open .custom-select-icon {
    transform: rotate(180deg);
}

.custom-select-list {
    position: absolute;
    z-index: 60;
    top: calc(100% + 0.375rem);
    left: 0;
    right: 0;
    display: none;
    max-height: 15rem;
    overflow-y: auto;
    border-radius: 0.5rem;
    border: 1px solid #dbe4ef;
    background: #fff;
    padding: 0.375rem;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.14);
    transform-origin: top;
    animation: menuIn 150ms ease-out;
}

.custom-select.is-open .custom-select-list {
    display: block;
}

.custom-select-option {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    border-radius: 0.375rem;
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 700;
    color: #334155;
    transition: background 150ms ease-out, color 150ms ease-out;
}

.custom-select-option:hover,
.custom-select-option.is-selected {
    background: #e0f2fe;
    color: #075985;
}

.custom-select-option.is-selected::after {
    content: "";
    width: 0.45rem;
    height: 0.75rem;
    border-right: 2px solid #18A8E0;
    border-bottom: 2px solid #18A8E0;
    transform: rotate(45deg);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #18A8E0;
    box-shadow: 0 0 0 3px rgba(24, 168, 224, 0.15);
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 800;
    color: #334155;
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    background: white;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.data-table {
    width: 100%;
    min-width: 44rem;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background: #f8fafc;
    padding: 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 900;
    color: #475569;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    border-top: 1px solid #e2e8f0;
    padding: 0.75rem;
    color: #334155;
    vertical-align: middle;
}

.data-table td:last-child {
    white-space: nowrap;
}

.data-table a,
.data-table button {
    display: inline-flex;
    min-height: 2rem;
    align-items: center;
    border-radius: 0.375rem;
}

.dropdown-panel {
    transform-origin: top right;
    animation: menuIn 150ms ease-out;
}

.modal-panel {
    animation: modalIn 180ms ease-out;
}

.modal-shell {
    padding-bottom: env(safe-area-inset-bottom);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes menuIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

@media (max-width: 640px) {
    .table-wrap {
        border-radius: 0.5rem;
    }

    .data-table {
        min-width: 40rem;
        font-size: 0.8125rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.65rem;
    }

    .modal-panel {
        border-radius: 0.75rem;
        padding: 1rem;
    }

    .custom-select-list {
        max-height: 12rem;
    }
}

/* Main content scroll */
.dashboard-main {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dashboard-main::-webkit-scrollbar {
    width: 6px;
}

.dashboard-main::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-main::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
}

.dashboard-main::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive table scroll indicator */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.overflow-x-auto::-webkit-scrollbar {
    height: 4px;
}

.overflow-x-auto::-webkit-scrollbar-track {
    background: transparent;
}

.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Mobile chart responsive */
@media (max-width: 1024px) {
    .dashboard-main canvas {
        max-height: 220px !important;
    }
}

/* Pagination responsive */
@media (max-width: 480px) {
    .flex.items-center.justify-between.border-t {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* Print styles */
@media print {
    body { background: white; }
    #sidebar, #sidebarOverlay, header, .no-print, #toastNotif { display: none !important; }
    .lg\:pl-60 { padding-left: 0 !important; }
    .dashboard-main { padding: 0 !important; }
    .overflow-x-auto { overflow: visible !important; }
    table { font-size: 10px; }
}
