/* ══════════════════════════════════════════════════════════════════════
   FT 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 */
*, *::before, *::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;
}

.btn-primary {
    color: #fff;
    background-color: #1565C0;
    border-color: #0D47A1;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #42A5F5;
}

.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+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4M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zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) 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;
    color: #856404;
    text-decoration: none;
    font-size: 1.2rem;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.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;
}

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

.ft-drawer {
    border-right: 1px solid var(--mud-palette-divider, #E0E0E0);
}

.ft-drawer .mud-drawer-header {
    min-height: 56px;
}

/* NavGroup icon muted — nổi bật hơn khi hover */
.mud-nav-group .mud-nav-link .mud-icon-root {
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.mud-nav-group .mud-nav-link:hover .mud-icon-root {
    opacity: 1;
}

/* Active nav item — accent bar bên trái */
.mud-navmenu .mud-nav-link.active {
    border-left: 3px solid var(--mud-palette-primary, #1565C0);
    background-color: var(--mud-palette-primary-hover, rgba(21,101,192,0.08));
    font-weight: 500;
}

/* Nav item hover — nhẹ nhàng */
.mud-navmenu .mud-nav-link:hover:not(.active) {
    background-color: var(--mud-palette-action-default-hover, rgba(0,0,0,0.04));
}

/* ── Cards & Paper Enhancement ───────────────────────────────────── */

/* Card hover effect cho dashboard cards */
.mud-card {
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.mud-card:hover {
    transform: translateY(-1px);
}

/* ── Button Enhancement ──────────────────────────────────────────── */

.mud-button-root {
    transition: all 0.15s ease;
}

/* ── Chip & Badge ────────────────────────────────────────────────── */

.mud-chip {
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* ── DataGrid compact styling ────────────────────────────────────── */

.mud-table-toolbar {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    min-height: 40px !important;
}

.mud-table-head .mud-table-cell {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.mud-table-body .mud-table-cell {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

.mud-table-pagination {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    min-height: 36px !important;
}

.mud-table-container {
    overflow-x: auto;
}

.mud-table-container > table {
    width: 100%;
}

/* Table row hover — smooth */
.mud-table-body .mud-table-row {
    transition: background-color 0.1s ease;
}

/* ── Dialog Enhancement ──────────────────────────────────────────── */

.mud-dialog {
    border-radius: 12px;
}

.mud-dialog .mud-dialog-title {
    font-weight: 600;
}

/* ── Snackbar Enhancement ────────────────────────────────────────── */

.mud-snackbar {
    border-radius: 8px;
}

/* ── Page Header Pattern ─────────────────────────────────────────── */

/* Consistent page header spacing */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* ── Responsive styling ──────────────────────────────────────────── */

@media (max-width: 599.98px) {
    .mud-main-content .mud-container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

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

    .mud-paper {
        padding: 8px !important;
    }

    .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;
    }
}

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

::-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);
}

/* Dark mode scrollbar */
.mud-theme-dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.mud-theme-dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Selection Color ─────────────────────────────────────────────── */

::selection {
    background: rgba(21, 101, 192, 0.2);
    color: inherit;
}

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

.ft-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);
}

.ft-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;
}

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

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

.ft-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 nav items */
    .mud-nav-link {
        min-height: 44px;
    }

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

/* ── Utility Classes ─────────────────────────────────────────────── */

.text-gradient-primary {
    background: linear-gradient(135deg, #1565C0, #42A5F5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Attendance Calendar ────────────────────────────────────────── */

.att-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.att-calendar-grid:last-of-type {
    border-bottom: none;
}

.att-calendar-header {
    background-color: var(--mud-palette-surface);
}

.att-calendar-header-cell {
    padding: 8px 4px;
    text-align: center;
    border-right: 1px solid var(--mud-palette-lines-default);
}

.att-calendar-header-cell:last-child {
    border-right: none;
}

.att-calendar-cell {
    min-height: 72px;
    border-right: 1px solid var(--mud-palette-lines-default);
    position: relative;
}

.att-calendar-cell:last-child {
    border-right: none;
}

.att-calendar-empty {
    background-color: var(--mud-palette-background);
    opacity: 0.5;
}

.att-calendar-day {
    padding: 4px 6px;
    cursor: default;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.att-calendar-day:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1;
}

.att-weekend {
    background-color: var(--mud-palette-background) !important;
}

.att-today {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
    z-index: 1;
}

.att-day-number {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--mud-palette-text-primary);
}

.att-today-number {
    background: var(--mud-palette-primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.att-day-times {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.att-time-in,
.att-time-out {
    font-size: 0.65rem;
    color: var(--mud-palette-text-secondary);
    line-height: 1.2;
}

.att-time-in::before {
    content: "↓ ";
    color: var(--mud-palette-success);
}

.att-time-out::before {
    content: "↑ ";
    color: var(--mud-palette-error);
}

.att-day-badge {
    position: absolute;
    top: 3px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    line-height: 1;
}

.att-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 16px;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
}

.att-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.att-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Responsive: mobile hiển thị nhỏ gọn hơn */
@media (max-width: 600px) {
    .att-calendar-cell {
        min-height: 52px;
    }
    .att-day-times {
        display: none;
    }
    .att-day-number {
        font-size: 0.75rem;
    }
    .att-calendar-legend {
        gap: 8px;
    }
}
