/* ══════════════════════════════════════════════════════════════════════
   COFFEE Platform — Global Styles
   Supports: Light + Dark mode via MudBlazor ThemeProvider
   ══════════════════════════════════════════════════════════════════════ */

/* ── Base ─────────────────────────────────────────────────────────── */

html, body {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Smooth transition khi chuyển dark/light mode — chỉ active SAU khi theme đã apply xong.
   Class .coffee-transitions-ready được thêm bởi MainLayout sau firstRender.
   Tránh FOUC: không transition trong lúc load ban đầu. */
html.coffee-transitions-ready *, html.coffee-transitions-ready *::before, html.coffee-transitions-ready *::after {
    transition: background-color 0.2s ease, color 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

a, .btn-link {
    color: #1565C0;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #2E7D32;
}

.invalid {
    outline: 1px solid #C62828;
}

.validation-message {
    color: #C62828;
}

/* ── Error Boundaries ────────────────────────────────────────────── */

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1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jcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    display: none;
    left: 0;
    padding: 0.8rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
    color: #856404;
    font-size: 0.95rem;
}

#blazor-error-ui .reload {
    color: #1565C0;
    font-weight: 600;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.6rem;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

html[data-coffee-dark="true"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

html[data-coffee-dark="true"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── ApexCharts Tooltip Dark Mode ────────────────────────────────
   ApexCharts tooltip render ở body level (portal), nằm ngoài .mud-theme-dark.
   Dùng html[data-coffee-dark="true"] selector. */
html[data-coffee-dark="true"] .apexcharts-tooltip {
    background: #1E1E2D !important;
    color: #E0E0E0 !important;
    border-color: #3a3a4a !important;
}

html[data-coffee-dark="true"] .apexcharts-tooltip .apexcharts-tooltip-title {
    background: #16161F !important;
    border-color: #3a3a4a !important;
    color: #E0E0E0 !important;
}

html[data-coffee-dark="true"] .apexcharts-xaxistooltip,
html[data-coffee-dark="true"] .apexcharts-yaxistooltip {
    background: #1E1E2D !important;
    color: #E0E0E0 !important;
    border-color: #3a3a4a !important;
}

/* ── Global Responsive ───────────────────────────────────────────── */

@media (max-width: 599.98px) {
    .mobile-hide {
        display: none !important;
    }

    .mud-main-content .mud-container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .mud-typography-h5 {
        font-size: 1.15rem !important;
    }

    .mud-main-content .mud-paper {
        padding: 8px !important;
        border-radius: 6px;
    }

    .mud-table-pagination .mud-typography {
        font-size: 0.75rem;
    }

    .mud-dialog {
        margin: 8px !important;
        max-width: calc(100vw - 16px) !important;
    }

    /* Hide card hover effect on mobile (no hover) */
    .mud-card:hover {
        transform: none;
    }
}

@media (min-width: 600px) and (max-width: 959.98px) {
    .mud-dialog {
        max-width: min(600px, 90vw) !important;
    }
}

@media (max-width: 480px) {
    /* Reduce table font size on small phones */
    .mud-table-cell, .mud-table-head th {
        font-size: 0.78rem;
        padding: 4px 8px;
    }
}

/* ── Mobile Bottom Navigation ───────────────────────────────────── */

.coffee-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1300;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    justify-content: space-around;
    align-items: center;
    padding: 4px 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.coffee-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--mud-palette-text-secondary);
    font-size: 0.65rem;
    font-weight: 500;
    min-width: 56px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.coffee-bottom-nav__item:active {
    background-color: var(--mud-palette-action-default-hover);
}

.coffee-bottom-nav__item.active {
    color: var(--mud-palette-primary);
}

.coffee-bottom-nav__item.active .mud-icon-root {
    color: var(--mud-palette-primary);
}

/* Padding bottom for main content on mobile to avoid bottom nav overlap */
@media (max-width: 959.98px) {
    .mud-main-content {
        padding-bottom: 64px !important;
    }
}

/* ── Touch-Friendly Enhancements ───────────────────────────────── */

@media (max-width: 959.98px) {
    /* Larger touch targets for buttons */
    .mud-icon-button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Larger touch targets for text buttons on mobile */
    .mud-button-root.mud-button {
        min-height: 44px;
    }

    /* Larger touch targets for nav items */
    .mud-nav-link {
        min-height: 44px;
    }

    /* More padding for form fields on touch */
    .mud-input-control .mud-input {
        min-height: 44px;
    }

    /* Allow filter bar buttons to wrap on narrow screens */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}

/* ── AppBar Glass Effect ──────────────────────────────────────────── */

.coffee-appbar.mud-appbar {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(13, 71, 161, 0.92) !important;
}

html[data-coffee-dark="true"] .coffee-appbar.mud-appbar {
    background: rgba(30, 30, 45, 0.88) !important;
}

/* ── Dashboard Cards ─────────────────────────────────────────────── */

.stat-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html[data-coffee-dark="true"] .stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.quick-action-card {
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.quick-action-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12) !important;
}

html[data-coffee-dark="true"] .quick-action-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35) !important;
}

/* ── MudBlazor Drawer Enhancement ────────────────────────────────── */

.coffee-drawer .mud-nav-link {
    transition: all 0.15s ease;
}

.coffee-drawer .mud-nav-link:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

html[data-coffee-dark="true"] .coffee-drawer .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
}
