/**
 * Mitaco Chấm Công — Custom Styles
 * Built on top of Carbon Design System
 */

/* ============================================
   ROOT VARIABLES & OVERRIDES
   ============================================ */
:root {
    /* Status colors */
    --status-late: #da1e28;
    --status-late-bg: #fff1f1;
    --status-ontime: #198038;
    --status-ontime-bg: #defbe6;
    --status-overtime: #0043ce;
    --status-overtime-bg: #edf5ff;
    --status-absent: #6f6f6f;
    --status-absent-bg: #f4f4f4;

    /* App */
    --app-header-height: 48px;
    --app-content-bg: #f4f4f4;
    --card-bg: #ffffff;
    --card-border: #e0e0e0;
}

/* ============================================
   GLOBAL
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    background: var(--app-content-bg);
    color: #161616;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   HEADER
   ============================================ */
.cds--header {
    background: #161616;
    border-bottom: none;
    z-index: 100;
}

.cds--header__name {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.cds--header__name--prefix {
    font-weight: 300;
}

.cds--header__menu-item svg {
    vertical-align: middle;
}

.cds--header__global {
    display: flex;
    align-items: center;
    gap: 0;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
    color: #c6c6c6;
    font-size: 0.8125rem;
    border-right: 1px solid #393939;
    height: 100%;
    white-space: nowrap;
}

.header-user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cds--header__action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: #c6c6c6;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 150ms ease;
    text-decoration: none;
}

.cds--header__action:hover {
    background: #353535;
    color: #fff;
}

/* ============================================
   APP MAIN
   ============================================ */
.app-main {
    padding-top: var(--app-header-height);
    min-height: 100vh;
}

.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 400;
    margin: 0;
    color: #161616;
    line-height: 1.25;
}

.page-header__subtitle {
    font-size: 0.875rem;
    color: #525252;
    margin: 0.25rem 0 0;
}

.page-header__actions {
    flex-shrink: 0;
    padding-top: 0.375rem;
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
    }

    .page-header h1 {
        font-size: 1.375rem;
    }
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 1.25rem 1.5rem 1.5rem;
    margin-bottom: 1rem;
}

.filter-bar__row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.filter-item--grow {
    flex: 1;
    min-width: 200px;
}

.filter-item--actions {
    min-width: auto;
}

.filter-actions-group {
    display: flex;
    gap: 0.25rem;
}

.filter-bar .cds--label {
    font-size: 0.75rem;
    color: #525252;
    margin-bottom: 0.375rem;
}

.filter-bar .cds--text-input--sm,
.filter-bar .cds--select-input--sm {
    height: 32px;
    font-size: 0.8125rem;
}

.filter-bar .cds--select-input--sm {
    min-width: 160px;
    padding-right: 2rem;
    background-color: #f4f4f4;
    border: none;
    border-bottom: 1px solid #8d8d8d;
    appearance: auto;
}

@media (max-width: 768px) {
    .filter-bar__row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-item {
        width: 100%;
        min-width: auto;
    }

    .filter-actions-group {
        width: 100%;
    }

    .filter-actions-group .cds--btn {
        flex: 1;
    }
}

/* ============================================
   STATS ROW
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1px;
    margin-bottom: 1rem;
    background: var(--card-border);
    border: 1px solid var(--card-border);
}

.stat-card {
    background: var(--card-bg);
    padding: 0.875rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-card__label {
    font-size: 0.75rem;
    color: #525252;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 400;
}

.stat-card__value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #161616;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-card__value--danger {
    color: var(--status-late);
}

.stat-card__value--success {
    color: var(--status-ontime);
}

@media (max-width: 640px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-card__value {
        font-size: 1.25rem;
    }
}

/* ============================================
   DATA TABLE
   ============================================ */
.data-table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cds--data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.cds--data-table thead th {
    background: #e0e0e0;
    color: #161616;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.625rem 1rem;
    white-space: nowrap;
    border-bottom: 1px solid #c6c6c6;
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
}

.cds--data-table tbody td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
    white-space: nowrap;
}

/* Zebra */
.cds--data-table--zebra tbody tr:nth-child(even) {
    background: #f4f4f4;
}

.cds--data-table tbody tr:hover {
    background: #e8e8e8;
}

.cds--data-table tbody tr.group-row td {
    background: #e8f0ff !important;
    border-top: 1px solid #c6d6ff;
    border-bottom: 1px solid #c6d6ff;
    font-weight: 600;
}

.group-row__meta {
    margin-left: 0.5rem;
    color: #525252;
    font-weight: 400;
}

/* Column widths */
.col-stt {
    width: 50px;
    text-align: center !important;
}

.col-manv {
    width: 100px;
}

.col-tennv {
    min-width: 220px;
}

.col-ngay {
    width: 120px;
}

.col-thu {
    width: 110px;
}

.col-giovao {
    width: 110px;
}

.col-giora {
    width: 110px;
}

.col-cong {
    width: 90px;
    text-align: center !important;
}

.col-phongban {
    min-width: 180px;
}

/* Sortable table headers */
.cds--data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.cds--data-table thead th.sortable::after {
    content: " \2195";
    color: #6f6f6f;
    font-size: 0.7rem;
    margin-left: 0.35rem;
}

.cds--data-table thead th.sortable.is-sort-asc::after {
    content: " \2191";
    color: #161616;
}

.cds--data-table thead th.sortable.is-sort-desc::after {
    content: " \2193";
    color: #161616;
}

/* STT center */
.cds--data-table tbody td:first-child {
    text-align: center;
    color: #6f6f6f;
    font-size: 0.75rem;
}

/* ============================================
   STATUS TAGS
   ============================================ */
.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 62.5rem;
    font-size: 0.6875rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.4;
}

.status-tag--late {
    background: var(--status-late-bg);
    color: var(--status-late);
}

.status-tag--ontime {
    background: var(--status-ontime-bg);
    color: var(--status-ontime);
}

.status-tag--overtime {
    background: var(--status-overtime-bg);
    color: var(--status-overtime);
}

.status-tag--absent {
    background: var(--status-absent-bg);
    color: var(--status-absent);
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */
.table-loading,
.table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 0.75rem;
    color: #6f6f6f;
    font-size: 0.875rem;
}

.table-empty p {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #393939;
}

.table-empty span {
    font-size: 0.8125rem;
    color: #6f6f6f;
}

/* Carbon loading spinner */
.cds--loading--small {
    width: 32px;
    height: 32px;
}

.cds--loading__svg {
    animation: cds-loading-rotate 0.69s linear infinite;
    width: 100%;
    height: 100%;
}

.cds--loading__stroke {
    fill: none;
    stroke: #0f62fe;
    stroke-width: 8;
    stroke-dasharray: 240;
    stroke-dashoffset: 40;
    stroke-linecap: round;
    animation: cds-loading-dash 1.4s ease-in-out infinite;
}

@keyframes cds-loading-rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes cds-loading-dash {
    0% {
        stroke-dashoffset: 240;
    }

    50% {
        stroke-dashoffset: 60;
    }

    100% {
        stroke-dashoffset: 240;
    }
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-top: none;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #525252;
}

.pagination-info .cds--label {
    margin-bottom: 0;
    font-size: 0.8125rem;
}

.pagination-select {
    width: 70px;
    height: 32px;
    font-size: 0.8125rem;
    border: none;
    border-bottom: 1px solid #8d8d8d;
    background: #f4f4f4;
}

.pagination-summary {
    color: #525252;
    font-variant-numeric: tabular-nums;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.pagination-page-info {
    padding: 0 0.75rem;
    color: #161616;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cds--btn--icon-only {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 640px) {
    .pagination-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
}

/* ============================================
   BUTTONS (Carbon overrides)
   ============================================ */
.cds--btn--sm {
    min-height: 32px;
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
}

.cds--btn--primary {
    background: #0f62fe;
    border: none;
    color: #fff;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.cds--btn--primary:hover {
    background: #0043ce;
}

.cds--btn--primary:active {
    background: #002d9c;
}

.cds--btn--primary:disabled {
    background: #c6c6c6;
    color: #8d8d8d;
    cursor: not-allowed;
}

.cds--btn--tertiary {
    background: transparent;
    border: 1px solid #0f62fe;
    color: #0f62fe;
    cursor: pointer;
    transition: all 150ms ease;
}

.cds--btn--tertiary:hover {
    background: #0f62fe;
    color: #fff;
}

.cds--btn--tertiary:disabled {
    border-color: #c6c6c6;
    color: #c6c6c6;
    cursor: not-allowed;
}

.cds--btn--tertiary:disabled:hover {
    background: transparent;
    color: #c6c6c6;
}

.cds--btn--ghost {
    background: transparent;
    border: none;
    color: #0f62fe;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.cds--btn--ghost:hover {
    background: #e0e0e0;
    color: #0043ce;
}

.cds--btn--ghost:disabled {
    color: #c6c6c6;
    cursor: not-allowed;
}

.cds--btn--ghost:disabled:hover {
    background: transparent;
}

/* ============================================
   TEXT INPUT (Carbon overrides)
   ============================================ */
.cds--text-input {
    height: 40px;
    font-size: 0.875rem;
    font-family: inherit;
    background: #f4f4f4;
    border: none;
    border-bottom: 1px solid #8d8d8d;
    padding: 0 1rem;
    color: #161616;
    width: 100%;
    outline: none;
    transition: border-color 150ms ease;
}

.cds--text-input:focus {
    border-bottom-color: #0f62fe;
    box-shadow: inset 0 -2px 0 #0f62fe;
}

.cds--text-input::placeholder {
    color: #a8a8a8;
}

.cds--text-input--sm {
    height: 32px;
    font-size: 0.8125rem;
}

/* Date inputs */
input[type="date"].cds--text-input {
    cursor: pointer;
}

/* ============================================
   LABEL
   ============================================ */
.cds--label {
    font-size: 0.75rem;
    font-weight: 400;
    color: #525252;
    margin-bottom: 0.5rem;
    display: block;
    line-height: 1.34;
}

/* ============================================
   INLINE NOTIFICATION
   ============================================ */
.cds--inline-notification {
    display: flex;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    min-width: 0;
    word-break: break-word;
}

.cds--inline-notification--error {
    background: #fff1f1;
    border-left: 3px solid #da1e28;
}

.cds--inline-notification__details {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.cds--inline-notification__icon {
    flex-shrink: 0;
    color: #da1e28;
    margin-top: 1px;
}

.cds--inline-notification__title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    color: #161616;
}

.cds--inline-notification__subtitle {
    font-size: 0.875rem;
    margin: 0.125rem 0 0;
    color: #525252;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: calc(var(--app-header-height) + 1rem);
    right: 1rem;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
    width: 100%;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    background: #161616;
    color: #f4f4f4;
    border-left: 3px solid #0f62fe;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: auto;
    font-size: 0.8125rem;
}

.toast--error {
    border-left-color: #da1e28;
}

.toast--success {
    border-left-color: #198038;
}

.toast--removing {
    animation: toastSlideOut 0.25s ease forwards;
}

.toast__message {
    flex: 1;
}

.toast__close {
    background: transparent;
    border: none;
    color: #a8a8a8;
    cursor: pointer;
    padding: 0;
    margin-left: 0.75rem;
    font-size: 1.125rem;
    line-height: 1;
}

.toast__close:hover {
    color: #fff;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ============================================
   SCROLL TO TOP (ACCESSIBILITY)
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   CUSTOM MULTI-SELECT DROPDOWN
   ============================================ */
.custom-multi-select {
    position: relative;
    width: 100%;
}

.custom-multi-select input[readonly] {
    cursor: pointer;
    background-color: var(--cds-field, #f4f4f4);
    padding-right: 2rem;
    text-overflow: ellipsis;
}

.multi-select-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    fill: var(--cds-icon-primary, #161616);
}

.custom-multi-select.is-open .multi-select-icon {
    transform: translateY(-50%) rotate(180deg);
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--card-bg, #ffffff);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--cds-border-subtle, #e0e0e0);
    z-index: 9000;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.multi-select-search {
    padding: 0.5rem;
    border-bottom: 1px solid var(--cds-border-subtle, #e0e0e0);
}

.multi-select-search input {
    width: 100%;
    border: none;
    background: #f4f4f4;
    padding: 0.5rem;
    font-size: 0.8125rem;
    outline: none;
}

.multi-select-options {
    overflow-y: auto;
    flex: 1;
}

.multi-select-option {
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.multi-select-option:hover {
    background-color: #e5e5e5;
}

.multi-select-empty {
    padding: 1rem;
    color: #525252;
    font-style: italic;
    cursor: default;
}

.multi-select-option:hover.multi-select-empty {
    background-color: transparent;
}

.multi-select-checkbox {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* ============================================
   INLINE EDIT
   ============================================ */
.col-action {
    width: 80px;
    text-align: center !important;
}

.cell-action {
    text-align: center;
    white-space: nowrap;
}

.btn-edit-row {
    padding: 0.25rem !important;
    min-height: 28px !important;
    width: 28px !important;
    color: #525252 !important;
}

.btn-edit-row:hover {
    color: #0f62fe !important;
    background: #e0e0e0 !important;
}

tr.is-editing {
    background-color: #fffbe6 !important;
    box-shadow: inset 0 0 0 2px #f1c21b;
}

tr.is-editing td {
    color: #161616 !important;
}

.edit-time-input {
    width: 120px;
    height: 28px;
    font-size: 0.8125rem;
    font-family: inherit;
    border: 1px solid #0f62fe;
    border-radius: 2px;
    padding: 0 0.5rem;
    background: #fff;
    outline: none;
    color: #161616;
}

.edit-time-input:focus {
    box-shadow: 0 0 0 2px #0f62fe;
}

.edit-actions {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.edit-actions .cds--btn--sm {
    padding: 0.25rem !important;
    min-height: 28px !important;
    width: 28px !important;
}

.btn-save-row {
    background: #198038 !important;
    border: none !important;
}

.btn-save-row:hover {
    background: #0e6027 !important;
}

.btn-cancel-row {
    color: #da1e28 !important;
}

.btn-cancel-row:hover {
    background: #fff1f1 !important;
}

/* Edited row indicator */
tr.row-edited td {
    position: relative;
}

.edited-badge {
    display: inline-block;
    font-size: 0.625rem;
    color: #0f62fe;
    margin-right: 0.25rem;
    vertical-align: middle;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .cds--header,
    .filter-bar,
    .stats-row,
    .pagination-bar,
    .page-header__actions,
    .toast-container,
    .col-action,
    .cell-action {
        display: none !important;
    }

    .app-main {
        padding-top: 0;
    }

    .app-container {
        max-width: none;
        padding: 0;
    }

    .data-table-wrapper {
        border: none;
        overflow: visible;
    }

    .cds--data-table {
        font-size: 9pt;
    }

    .page-header h1 {
        font-size: 14pt;
    }
}
