/* HMIS Global Stylesheet */

/* Material Symbols - FOUT Prevent Layout Shift */
html:not(.fonts-loaded) .material-symbols-outlined {
    color: transparent !important;
    max-width: 1em;
    overflow: hidden;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

html {
    scroll-behavior: smooth;
}
body {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
    color: #1a1c1e;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5 {
    font-family: 'Public Sans', sans-serif;
    letter-spacing: -0.01em;
}

/* Sidebar active state */
aside a.active,
aside a.border-l-4 {
    border-left: 4px solid #003f87;
    background-color: #ffffff;
    color: #003f87;
    font-weight: 700;
}

/* Table styles */
.hmis-table {
    width: 100%;
    border-collapse: collapse;
}
.hmis-table thead tr {
    background-color: #f2f3fd;
}
.hmis-table thead th {
    padding: 1rem 1.25rem;
    font-size: 0.6875rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #424752;
    text-align: left;
}
.hmis-table tbody tr {
    border-bottom: 1px solid rgba(194, 198, 212, 0.2);
    transition: background-color 0.15s ease;
}
.hmis-table tbody tr:hover {
    background-color: #f2f3fd;
}
.hmis-table tbody td {
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
}

/* Form Input & Dropdown styles */
.hmis-input {
    width: 100%;
    background-color: #f8fafc;
    border: 1px solid #c2c6d4;
    border-radius: 0.5rem;
    padding: 0.65rem 1rem;
    font-family: 'Inter', sans-serif;
    color: #191b22;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.hmis-input:focus {
    background-color: #ffffff;
    border-color: #003f87;
    box-shadow: 0 0 0 3px rgba(0,63,135,0.1);
    outline: none;
}
.hmis-input::placeholder {
    color: #8f95a3;
    font-weight: 400;
}
select.hmis-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23424752'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    cursor: pointer;
}
select.hmis-input:hover {
    border-color: #a1a6b5;
}

/* Labels */
.hmis-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #727784;
    margin-bottom: 0.375rem;
    margin-left: 0.25rem;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-dot {
    width: 0.25rem;
    height: 0.25rem;
    border-radius: 9999px;
}
.badge-active { background-color: #a0f399; color: #217128; }
.badge-delivered { background-color: #a0f399; color: #217128; }
.badge-inactive { background-color: #e1e2ec; color: #424752; }
.badge-pending { background-color: #e1e2ec; color: #424752; }
.badge-processing { background-color: #d7e2ff; color: #004491; }
.badge-suspended { background-color: #ffdad6; color: #93000a; }
.badge-terminated { background-color: #ffdad6; color: #93000a; }
.badge-cancelled { background-color: #ffdad6; color: #93000a; }
.badge-on-leave { background-color: #ffdbcc; color: #7b2f00; }
.badge-planning { background-color: #e1e2ec; color: #424752; }
.badge-completed { background-color: #a3f69c; color: #002204; }
.badge-on-hold { background-color: #ffdbcc; color: #7b2f00; }
.badge-critical { background-color: #ffdad6; color: #93000a; }
.badge-high { background-color: #ffdbcc; color: #7b2f00; }
.badge-medium { background-color: #d7e2ff; color: #004491; }
.badge-low { background-color: #a0f399; color: #217128; }
.badge-resolved { background-color: #a3f69c; color: #002204; }
.badge-monitoring { background-color: #d7e2ff; color: #004491; }
.badge-draft { background-color: #e1e2ec; color: #424752; }
.badge-approved { background-color: #a0f399; color: #217128; }
.badge-closed { background-color: #e1e2ec; color: #424752; }

/* KPI Cards */
.kpi-card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 1.75rem;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 63, 135, 0.2);
}
.kpi-card-primary {
    background: linear-gradient(135deg, #003f87 0%, #002952 100%);
    border-radius: 1.25rem;
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 63, 135, 0.3);
}

/* Pagination */
.pg-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: #ffffff;
    border: 1px solid rgba(194, 198, 212, 0.3);
    color: #424752;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.pg-btn:hover {
    background: #003f87;
    color: #ffffff;
    border-color: #003f87;
}
.pg-btn.current {
    background: #003f87;
    color: #ffffff;
    border-color: #003f87;
}

/* Action Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #003f87;
    color: #ffffff;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 63, 135, 0.2);
}
.btn-primary:hover {
    background: #002d61;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 63, 135, 0.3);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #217128;
    color: #ffffff;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(33, 113, 40, 0.2);
}
.btn-secondary:hover {
    background: #1b5e21;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(33, 113, 40, 0.3);
}
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.6rem 1.25rem;
    background: transparent;
    color: #424752;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(194, 198, 212, 0.5);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}
.btn-ghost:hover {
    background: #e7e7f1;
}
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: #ffdad6;
    color: #93000a;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease;
}
.btn-danger:hover { opacity: 0.85; }

.btn-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
    text-decoration: none;
    color: #424752;
    font-size: 1.1rem;
}
.btn-icon:hover { background: #e7e7f1; color: #003f87; }
.btn-icon.danger:hover { background: #ffdad6; color: #93000a; }

/* Section card */
.section-card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 2rem;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #c2c6d4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #727784; }

/* Responsive Tables (Mobile First Cards) */
@media (max-width: 768px) {
    .section-card {
        padding: 1.25rem;
        background: transparent;
        box-shadow: none;
    }
    .section-card.p-0 {
        background: transparent;
        box-shadow: none;
        overflow-x: visible !important;
    }
    
    .hmis-table, .hmis-table tbody, .hmis-table tr, .hmis-table td {
        display: block;
        width: 100%;
    }
    .hmis-table thead {
        display: none;
    }
    .hmis-table tr {
        margin-bottom: 1.25rem;
        background: #ffffff;
        border-radius: 0.75rem;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
        border: 1px solid #e1e2ec;
        overflow: hidden;
    }
    .hmis-table tbody tr {
        border-bottom: none;
    }
    .hmis-table tbody tr:hover {
        background: #ffffff;
    }
    .hmis-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.875rem 1rem !important;
        border-bottom: 1px solid rgba(194, 198, 212, 0.2);
        text-align: right;
        gap: 1rem;
    }
    .hmis-table td:last-child {
        border-bottom: none;
        background: #f8fafc;
        justify-content: space-between; /* usually Actions label + buttons */
    }
    .hmis-table td::before {
        content: attr(data-label);
        font-size: 0.6875rem;
        font-weight: 800;
        text-transform: uppercase;
        color: #727784;
        text-align: left;
        flex-shrink: 0;
    }
    /* Fix inner flex items targeting for right alignment */
    .hmis-table td > .flex {
        text-align: right;
        justify-content: flex-end;
    }
}

/* Animate */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease both; }
