/**
 * Responsive layer — Bootstrap 5.3+ companion
 * Breakpoints: sm 576, md 768, lg 992, xl 1200
 */

/* -------------------------------------------------------------------------- */
/* Typography — mobile-first scaling                                              */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    html {
        font-size: 15px;
    }

    main.app-main h1.h3,
    main.app-main .h3 {
        font-size: 1.25rem;
    }

    main.app-main h1.h4,
    main.app-main .h4 {
        font-size: 1.15rem;
    }

    .page-hero h1 {
        font-size: 1.35rem;
    }
}

@media (min-width: 768px) {
    main.app-main .page-title-lg {
        font-size: 1.5rem;
    }
}

/* -------------------------------------------------------------------------- */
/* Layout                                                                       */
/* -------------------------------------------------------------------------- */
main.app-main {
    max-width: 100%;
}

.app-guest-logo {
    width: auto;
    height: 40px;
    max-height: 48px;
    max-width: min(180px, 42vw);
    object-fit: contain;
}

.app-brand-logo {
    height: 36px;
    max-height: 40px;
    max-width: min(160px, 38vw);
    width: auto;
    object-fit: contain;
}

.app-brand-title {
    font-weight: 700;
    font-size: clamp(0.85rem, 2.8vw, 1.05rem);
    max-width: 55vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 992px) {
    .app-brand-title {
        max-width: 18rem;
        white-space: normal;
    }
}

/* -------------------------------------------------------------------------- */
/* Sidebar + top bar — touch targets, mobile                                    */
/* -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .app-sidebar-link,
    .app-sidebar-group__toggle {
        min-height: 44px;
    }

    .app-sidebar-sublink {
        min-height: 40px;
        display: flex;
        align-items: center;
    }

    .app-topbar__dropdown {
        width: min(100vw - 2rem, 18rem);
    }
}

.app-topbar__dropdown .dropdown-item-text {
    font-size: 0.875rem;
}

.app-topbar__dropdown .dropdown-item:active {
    background-color: rgba(13, 110, 253, 0.12);
}

/* -------------------------------------------------------------------------- */
/* Forms — single column mobile, tap-friendly                                   */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .form-control:not(.form-control-sm),
    .form-select:not(.form-select-sm) {
        min-height: 44px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .btn:not(.btn-sm):not(.btn-xs) {
        min-height: 44px;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .btn-group-vertical-mobile {
        flex-direction: column;
        width: 100%;
    }

    .btn-group-vertical-mobile > .btn {
        border-radius: var(--bs-border-radius) !important;
        margin-bottom: 0.5rem;
    }

    .btn-group-vertical-mobile > .btn:last-child {
        margin-bottom: 0;
    }
}

/* Full-width primary actions on small screens */
@media (max-width: 575.98px) {
    .btn-mobile-block {
        width: 100%;
    }

    .d-grid-mobile {
        display: grid !important;
        gap: 0.5rem;
    }
}

@media (min-width: 576px) {
    .btn-mobile-block-sm {
        width: auto;
    }
}

/* -------------------------------------------------------------------------- */
/* Tables — horizontal scroll; attendance daily sticky identity columns         */
/* -------------------------------------------------------------------------- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.att-daily-table-wrap {
    border-radius: 0 0 var(--as-radius-sm, 0.5rem) var(--as-radius-sm, 0.5rem);
}

.att-daily-table {
    min-width: 920px;
    font-size: 0.875rem;
}

@media (max-width: 767.98px) {
    .att-daily-table {
        font-size: 0.8125rem;
    }

    .att-daily-table > thead > tr > th,
    .att-daily-table > tbody > tr > td {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Sticky #, Code, Name so employee identity stays visible while scrolling */
.att-daily-table thead th.att-daily-sticky,
.att-daily-table tbody td.att-daily-sticky {
    position: sticky;
    background-color: var(--as-surface, #fff);
    z-index: 2;
    box-shadow: 4px 0 10px rgba(15, 23, 42, 0.06);
}

.att-daily-table thead th.att-daily-sticky {
    z-index: 4;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%) !important;
    color: #f1f5f9 !important;
}

.att-daily-table thead th.att-daily-sticky--1 {
    left: 0;
    min-width: 2.25rem;
}

.att-daily-table thead th.att-daily-sticky--2 {
    left: 2.5rem;
    min-width: 4.5rem;
}

.att-daily-table thead th.att-daily-sticky--3 {
    left: 7.25rem;
    min-width: 9rem;
}

.att-daily-table tbody td.att-daily-sticky--1 {
    left: 0;
}

.att-daily-table tbody td.att-daily-sticky--2 {
    left: 2.5rem;
}

.att-daily-table tbody td.att-daily-sticky--3 {
    left: 7.25rem;
}

.att-daily-table tbody tr.table-warning > td.att-daily-sticky {
    background-color: var(--bs-warning-bg-subtle, #fff3cd) !important;
}

.att-daily-table thead th.att-col-status {
    min-width: 11rem;
}

.att-daily-table thead th.att-col-leave {
    min-width: 10rem;
}

.att-daily-table thead th.att-col-ot {
    min-width: 7rem;
}

.att-daily-table thead th.att-col-saved {
    min-width: 9rem;
}

.att-leave-select {
    max-width: 11rem;
}

@media (max-width: 767.98px) {
    .att-leave-select {
        max-width: 100%;
    }

    .att-bulk-actions {
        flex-direction: column;
        align-items: stretch !important;
    }

    .att-bulk-actions .btn {
        width: 100%;
        min-height: 44px;
    }
}

/* Monthly report table — slightly smaller cells on phone */
@media (max-width: 767.98px) {
    .att-monthly-table {
        font-size: 0.75rem;
    }

    .att-monthly-table .att-cell {
        min-width: 1.5rem;
        padding: 0.2rem !important;
    }
}

/* -------------------------------------------------------------------------- */
/* Cards & dashboard                                                            */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .dashboard-card .card-body {
        padding: 1rem;
    }

    .quick-link-card .card-body {
        padding: 1rem 1.1rem;
    }
}

/* -------------------------------------------------------------------------- */
/* Modals — full width on small viewports                                       */
/* -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        max-height: calc(100vh - 1rem);
    }

    .modal-body {
        overflow-y: auto;
    }

    .employee-form-page .employee-form-shell {
        max-width: 100%;
    }

    .employee-form-page .employee-form-section__head {
        padding: 1rem 1rem 0.85rem;
    }

    .employee-form-page .employee-form-scan-row {
        padding: 0.75rem 0.85rem;
    }

    .employee-form-page .employee-form-scan-row .btn,
    .employee-form-page .doc-capture-open {
        width: 100%;
        justify-content: center;
    }

    .employee-form-page .employee-form-segmented {
        width: 100%;
    }

    .employee-form-page .employee-form-segmented .btn {
        width: 100%;
    }
}

/* -------------------------------------------------------------------------- */
/* Page headers — stack primary actions on narrow screens                        */
/* -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    .page-toolbar .btn.btn-primary {
        width: 100%;
    }
}

/* -------------------------------------------------------------------------- */
/* Auth — login logo (no inline styles)                                            */
/* -------------------------------------------------------------------------- */
.auth-login-logo {
    max-height: 120px;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Narrow master forms (replaces inline max-width) */
.form-page-narrow {
    max-width: 640px;
}

/* -------------------------------------------------------------------------- */
/* Utilities                                                                    */
/* -------------------------------------------------------------------------- */
.gap-stack-sm {
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .gap-stack-sm {
        gap: 1rem;
    }
}

/* -------------------------------------------------------------------------- */
/* Attendance — mobile: touch targets + smooth horizontal scroll                 */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    .att-bulk-actions {
        gap: 0.5rem !important;
    }

    .att-bulk-actions .btn {
        min-height: 44px;
    }

    .att-daily-table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    .att-daily-table .form-select-sm,
    .att-daily-table .form-control-sm {
        min-height: 44px;
        font-size: 1rem;
    }
}
