/* ============================================================
   Angkain UI Theme — Shadcn-inspired component overrides
   Compatible with Filament v5 + Tailwind CSS
   ============================================================ */

/* ── CSS Variables (Shadcn design tokens) ─────────────────── */
:root {
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --radius-lg: 0.625rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ── Font Global ──────────────────────────────────────────── */
*, *::before, *::after {
    font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.fi-sidebar {
    border-right: 1px solid rgb(var(--gray-200));
    box-shadow: none !important;
}
.dark .fi-sidebar {
    border-right: 1px solid rgb(var(--gray-800));
}
.fi-sidebar-nav-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.5;
}
.fi-sidebar-item-button {
    border-radius: var(--radius) !important;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}
.fi-sidebar-item-button:hover {
    background-color: rgb(var(--gray-100));
}
.dark .fi-sidebar-item-button:hover {
    background-color: rgb(var(--gray-800));
}
.fi-sidebar-item-button.fi-active {
    background-color: rgb(var(--primary-50));
    color: rgb(var(--primary-700));
    font-weight: 600;
}
.dark .fi-sidebar-item-button.fi-active {
    background-color: rgb(var(--primary-950));
    color: rgb(var(--primary-300));
}

/* ── Topbar / Header ──────────────────────────────────────── */
.fi-topbar {
    border-bottom: 1px solid rgb(var(--gray-200));
    box-shadow: none !important;
    backdrop-filter: blur(8px);
    background-color: rgb(255 255 255 / 0.9);
}
.dark .fi-topbar {
    border-bottom: 1px solid rgb(var(--gray-800));
    background-color: rgb(var(--gray-900) / 0.9);
}

/* ── Cards / Sections ─────────────────────────────────────── */
.fi-section,
.fi-card {
    border-radius: var(--radius-lg) !important;
    border: 1px solid rgb(var(--gray-200)) !important;
    box-shadow: var(--shadow-sm) !important;
}
.dark .fi-section,
.dark .fi-card {
    border: 1px solid rgb(var(--gray-800)) !important;
}
.fi-section-header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgb(var(--gray-100));
}
.dark .fi-section-header {
    border-bottom: 1px solid rgb(var(--gray-800));
}

/* ── Buttons ──────────────────────────────────────────────── */
.fi-btn {
    border-radius: var(--radius) !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    letter-spacing: 0.01em;
    transition: all 0.15s ease !important;
    box-shadow: var(--shadow-sm) !important;
}
.fi-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow) !important;
}
.fi-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm) !important;
}
.fi-btn-size-sm {
    font-size: 0.8125rem !important;
}

/* ── Form Inputs ──────────────────────────────────────────── */
.fi-input,
.fi-select-input,
.fi-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    border-radius: var(--radius) !important;
    border: 1px solid rgb(var(--gray-300)) !important;
    font-size: 0.875rem !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
}
.fi-input:focus,
.fi-select-input:focus,
.fi-textarea:focus {
    border-color: rgb(var(--primary-500)) !important;
    box-shadow: 0 0 0 3px rgb(var(--primary-500) / 0.15) !important;
    outline: none !important;
}
.dark .fi-input,
.dark .fi-select-input,
.dark .fi-textarea {
    border: 1px solid rgb(var(--gray-700)) !important;
    background-color: rgb(var(--gray-900)) !important;
}

/* ── Tables ───────────────────────────────────────────────── */
.fi-ta-table {
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
    border: 1px solid rgb(var(--gray-200)) !important;
}
.dark .fi-ta-table {
    border: 1px solid rgb(var(--gray-800)) !important;
}
.fi-ta-header-cell {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgb(var(--gray-500)) !important;
    background-color: rgb(var(--gray-50)) !important;
}
.dark .fi-ta-header-cell {
    background-color: rgb(var(--gray-900)) !important;
    color: rgb(var(--gray-400)) !important;
}
.fi-ta-row:hover td {
    background-color: rgb(var(--gray-50)) !important;
}
.dark .fi-ta-row:hover td {
    background-color: rgb(var(--gray-800) / 0.5) !important;
}

/* ── Badges / Status ──────────────────────────────────────── */
.fi-badge {
    border-radius: 9999px !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.6rem !important;
}

/* ── Modal ────────────────────────────────────────────────── */
.fi-modal-window {
    border-radius: calc(var(--radius-lg) * 1.5) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid rgb(var(--gray-200));
}
.dark .fi-modal-window {
    border: 1px solid rgb(var(--gray-700));
}
.fi-modal-header {
    border-bottom: 1px solid rgb(var(--gray-100));
    padding-bottom: 1rem;
}
.dark .fi-modal-header {
    border-bottom: 1px solid rgb(var(--gray-800));
}

/* ── Stats / Widgets ──────────────────────────────────────── */
.fi-wi-stats-overview-stat {
    border-radius: var(--radius-lg) !important;
    border: 1px solid rgb(var(--gray-200)) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow 0.2s, transform 0.2s;
}
.fi-wi-stats-overview-stat:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-2px);
}
.dark .fi-wi-stats-overview-stat {
    border: 1px solid rgb(var(--gray-800)) !important;
}

/* ── Dropdown ─────────────────────────────────────────────── */
.fi-dropdown-panel {
    border-radius: var(--radius-lg) !important;
    border: 1px solid rgb(var(--gray-200)) !important;
    box-shadow: var(--shadow-md) !important;
}
.dark .fi-dropdown-panel {
    border: 1px solid rgb(var(--gray-700)) !important;
}
.fi-dropdown-list-item-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ── Notification Toast ───────────────────────────────────── */
.fi-no-notification {
    border-radius: var(--radius-lg) !important;
    border: 1px solid rgb(var(--gray-200)) !important;
    box-shadow: var(--shadow-lg) !important;
}
.dark .fi-no-notification {
    border: 1px solid rgb(var(--gray-700)) !important;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.fi-tabs-tab {
    border-radius: var(--radius) !important;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background-color 0.15s;
}

/* ── Breadcrumbs ──────────────────────────────────────────── */
.fi-breadcrumbs-item-label {
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ── Page Header ──────────────────────────────────────────── */
.fi-header-heading {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
}
.fi-header-subheading {
    font-size: 0.875rem;
    opacity: 0.6;
}

/* ── Custom Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #5b8cdf;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #033097;
}
.dark ::-webkit-scrollbar-thumb {
    background: #03AEB6;
}
.dark ::-webkit-scrollbar-thumb:hover {
    background: #02c4cf;
}
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #5b8cdf transparent;
}

/* ── Button Color Fixes ───────────────────────────────────── */
/* Primary buttons */
.fi-btn.fi-color-primary,
.fi-btn[class*="fi-color-primary"] {
    background-color: #033097 !important;
    color: #ffffff !important;
    border-color: #033097 !important;
}
.fi-btn.fi-color-primary:hover {
    background-color: #022578 !important;
    border-color: #022578 !important;
}

/* Gray / default buttons — make visible */
.fi-btn.fi-color-gray,
.fi-btn[class*="fi-color-gray"] {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
}
.fi-btn.fi-color-gray:hover {
    background-color: #e5e7eb !important;
    border-color: #9ca3af !important;
}

/* Success buttons */
.fi-btn.fi-color-success {
    background-color: #16a34a !important;
    color: #ffffff !important;
    border-color: #16a34a !important;
}
.fi-btn.fi-color-success:hover {
    background-color: #15803d !important;
}

/* Danger buttons */
.fi-btn.fi-color-danger {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}
.fi-btn.fi-color-danger:hover {
    background-color: #b91c1c !important;
}

/* Warning buttons */
.fi-btn.fi-color-warning {
    background-color: #d97706 !important;
    color: #ffffff !important;
    border-color: #d97706 !important;
}

/* Form action buttons — Save / Cancel area */
.fi-form-actions .fi-btn,
[class*="fi-ac-btn"],
.fi-ac-action {
    min-width: 5rem;
}

/* Outlined / link-style buttons — ensure they have visible border */
.fi-btn-outlined,
.fi-btn[data-outlined] {
    background-color: transparent !important;
    border: 1px solid #033097 !important;
    color: #033097 !important;
}
.fi-btn-outlined:hover {
    background-color: #eff4ff !important;
}

/* Active nav item stronger highlight */
.fi-sidebar-item-button.fi-active {
    background-color: rgb(var(--primary-600)) !important;
    color: #ffffff !important;
}
.fi-sidebar-item-button.fi-active .fi-sidebar-item-icon,
.fi-sidebar-item-button.fi-active span {
    color: #ffffff !important;
}
.dark .fi-sidebar-item-button.fi-active {
    background-color: rgb(var(--primary-700)) !important;
    color: #ffffff !important;
}

/* Link / action color */
a.fi-link, .fi-ta-col-action {
    color: rgb(var(--primary-600)) !important;
}
a.fi-link:hover {
    color: rgb(var(--primary-700)) !important;
}

/* ── Back to Top Button ───────────────────────────────────── */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 2.75rem;
    height: 2.75rem;
    background-color: #033097;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(3, 48, 151, 0.45);
    z-index: 99999;
    opacity: 0;
    transform: translateY(12px) scale(0.9);
    transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.15s, box-shadow 0.15s;
    pointer-events: none;
}
#back-to-top.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
#back-to-top:hover {
    background-color: #022578;
    box-shadow: 0 6px 18px rgba(3, 48, 151, 0.55);
    transform: translateY(-2px) scale(1);
}
#back-to-top svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: #ffffff;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Panel Switch Redesign ────────────────────────────────── */
/* Trigger button in topbar */
[id="panel-switch-trigger"],
.fi-panel-switch-trigger,
[x-data*="panel-switch"] > button,
button[x-on\:click*="panel-switch"] {
    border-radius: var(--radius) !important;
    padding: 0.375rem 0.625rem !important;
    border: 1px solid rgb(var(--gray-200)) !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    background: #fff !important;
    transition: all 0.15s !important;
}
button[x-on\:click*="panel-switch"]:hover {
    background: rgb(var(--gray-50)) !important;
    border-color: rgb(var(--primary-300)) !important;
    color: rgb(var(--primary-600)) !important;
}
/* Panel switch modal content */
.panel-switch-modal .fi-modal-window {
    max-width: 320px !important;
}
.panel-switch-modal .fi-dropdown-list-item {
    border-radius: var(--radius) !important;
    margin: 0.125rem 0.25rem;
    padding: 0.625rem 0.75rem !important;
}
