/* =========================================================================
HALLO TIM ENTERPRISE HRIS - REUSABLE UI COMPONENTS (components.css)
Cards, Tombol Universal, Custom Responsive Tables, Badges, Toast,
Desktop Center Modal, Mobile Bottom Sheet System, & Global Preloader
========================================================================= */

/* ================= 0. GLOBAL APP PRELOADER & LOADING SCREEN ================= */
.app-global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #11261f 0%, #081611 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
}

.app-global-loader.fade-out {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.loader-content-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 28px;
    max-width: 360px;
    width: 90%;
    background: rgba(17, 34, 28, 0.78);
    border: 1px solid rgba(134, 239, 172, 0.18);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    animation: loaderPopIn 0.35s ease-out forwards;
}

@keyframes loaderPopIn {
    from {
        transform: scale(0.92);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.loader-logo-wrapper {
    position: relative;
    width: 76px;
    height: 76px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-logo-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 16px;
    background-color: #0f172a;
    border: 2px solid var(--primary);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    position: relative;
    z-index: 2;
}

.loader-pulse-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 20px;
    border: 2px solid var(--primary-accent);
    opacity: 0.8;
    animation: pulseRing 1.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    z-index: 1;
}

@keyframes pulseRing {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.2;
    }

    100% {
        transform: scale(1.25);
        opacity: 0;
    }
}

.loader-title {
    font-size: 1.25rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.loader-title span {
    color: var(--primary-accent);
}

.loader-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 22px;
    letter-spacing: 0.3px;
}

.loader-spinner-bar {
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
    margin-bottom: 14px;
}

.loader-spinner-indicator {
    position: absolute;
    height: 100%;
    width: 45%;
    background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
    border-radius: 9999px;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.8);
    animation: shimmerLoaderBar 1.5s infinite ease-in-out;
}

@keyframes shimmerLoaderBar {
    0% {
        left: -45%;
    }

    50% {
        left: 40%;
        width: 55%;
    }

    100% {
        left: 100%;
        width: 45%;
    }
}

.loader-status {
    font-size: 0.74rem;
    font-weight: 700;
    color: #60a5fa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 20px;
    letter-spacing: 0.2px;
}

/* ================= 1. CARD CONTAINERS ================= */
.card {
    background-color: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    margin-bottom: 20px;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-body {
    padding: 16px 18px;
}

/* ================= 2. RESPONSIVE TABLES & PERMISSION MATRIX ================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.custom-table th {
    padding: 10px 12px;
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.permission-matrix-table td {
    padding: 8px 12px;
}

.permission-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ================= 3. BADGES & STATUS PILLS ================= */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-primary {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-secondary {
    background-color: #e2e8f0;
    color: #475569;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 9999px;
    font-size: 0.68rem;
    font-weight: 800;
}

.status-pill.active {
    background-color: #dcfce7;
    color: #15803d;
}

.status-pill.inactive {
    background-color: #fee2e2;
    color: #b91c1c;
}

/* ================= 4. BUTTONS & ACTIONS ================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed !important;
}

.btn-sm {
    padding: 4px 9px;
    font-size: 0.74rem;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.btn-success {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-success:hover {
    background-color: var(--primary-dark);
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.btn-warning {
    background-color: #f59e0b;
    color: #ffffff;
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-outline-secondary {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: var(--text-muted);
}

/* ================= 5. FORM INPUTS & LABELS ================= */
.form-group {
    margin-bottom: 14px;
    width: 100%;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-main);
}

.form-control,
.form-control-sm {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.84rem;
    font-family: inherit;
    background-color: #ffffff;
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.20);
}

.form-control-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* ================= 6. MODAL SYSTEM ================= */
.modal-backdrop,
.auth-backdrop,
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(9, 26, 19, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    overflow: hidden;
}

.modal-dialog {
    width: 100%;
    max-width: 460px;
    animation: modalScaleIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    position: relative;
}

.modal-dialog.modal-md {
    max-width: 620px;
}

.modal-dialog.modal-lg {
    max-width: 820px;
}

@keyframes modalScaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content {
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.modal-drag-handle {
    display: none;
    width: 44px;
    height: 4.5px;
    background-color: #cbd5e1;
    border-radius: 9999px;
    margin: 10px auto 4px auto;
    flex-shrink: 0;
}

.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.15s, background-color 0.15s;
}

.btn-close:hover {
    color: var(--danger);
    background-color: #fee2e2;
}

.modal-body {
    padding: 18px;
    max-height: calc(85vh - 120px);
    overflow-y: auto;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background-color: #f8fafc;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ================= 7. TOAST NOTIFICATIONS ================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 4000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 90vw;
}

.toast-item {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background-color: var(--sidebar-bg);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.25s ease-out;
}

.toast-item.success {
    border-left: 4px solid var(--success);
}

.toast-item.error {
    border-left: 4px solid var(--danger);
}

.toast-item.warning {
    border-left: 4px solid var(--warning);
}

.toast-item.info {
    border-left: 4px solid var(--info);
}

@keyframes toastSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ================= 8. MOBILE BOTTOM SHEET & RESPONSIVE ================= */
@media (max-width: 768px) {
    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .modal-dialog,
    .modal-dialog.modal-md,
    .modal-dialog.modal-lg {
        max-width: 100%;
        width: 100%;
        margin: 0;
        animation: modalSlideUp 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0.8;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .modal-content {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: 22px;
        border-top-right-radius: 22px;
        max-height: 90vh;
        border: none;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
    }

    .modal-drag-handle {
        display: block;
    }

    .modal-header {
        padding: 8px 16px 12px 16px;
        border-bottom: 1px solid #f1f5f9;
    }

    .modal-header h3 {
        font-size: 0.92rem;
    }

    .modal-body {
        padding: 14px 16px;
        max-height: calc(88vh - 135px);
    }

    .modal-footer {
        padding: 10px 16px max(14px, env(safe-area-inset-bottom, 14px)) 16px;
    }

    .toast-container {
        bottom: 74px;
        right: 14px;
        left: 14px;
        max-width: calc(100vw - 28px);
    }
}