/* ==================== GLOBAL ZOOM ==================== */
body {
    zoom: 0.8;
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ==================== LOADING SPINNER ==================== */
.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 100px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== TABLE CONTAINER ==================== */
#table-container {
    position: relative;
    height: calc(100vh - 220px);
    overflow: auto;
    background: #f8fafc;
    scroll-behavior: smooth;
}

/* ==================== TABLE STYLES ==================== */
table {
    border-collapse: collapse;
    width: 100%;
    min-width: 1400px;
    font-size: 0.875rem;
}

/* ==================== TABLE HEADER (STICKY) ==================== */
thead {
    position: sticky !important;
    top: 0;
    z-index: 30 !important;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

thead th {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #cbd5e1;
}

/* Header with sticky columns = highest z-index */
thead th.sticky-left,
thead th.sticky-right-40,
thead th.sticky-right-0 {
    z-index: 50 !important;
    background: #f1f5f9;
}

/* ==================== STICKY COLUMNS ==================== */
.sticky-left {
    position: sticky !important;
    left: 0;
    z-index: 20 !important;
    background: white;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.sticky-right-40 {
    position: sticky !important;
    right: 40px;
    z-index: 20 !important;
    background: white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.05);
}

.sticky-right-0 {
    position: sticky !important;
    right: 0;
    z-index: 20 !important;
    background: white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.05);
}

/* ==================== TABLE CELLS ==================== */
table th,
table td {
    border: 1px solid #cbd5e1;
    padding: 0;
}

/* ==================== TABLE INPUT STYLES ==================== */
table input {
    width: 100%;
    height: 100%;
    padding: 0.5rem;
    border: none;
    background: transparent;
    outline: none;
    transition: all 0.2s ease;
}

table input:focus {
    background: #eff6ff !important;
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    z-index: 10;
}

table input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

table input[type="number"] {
    text-align: center;
    font-family: 'Courier New', monospace;
    color: #059669;
    font-weight: 700;
}

/* ==================== SORT BUTTON STYLES ==================== */
thead th button {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.25rem;
    border-radius: 0.25rem;
    background: none;
    border: none;
    color: inherit;
}

thead th button:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.02);
}

thead th button svg {
    transition: transform 0.2s ease;
}

thead th button:hover svg {
    transform: scale(1.2);
}

thead th button.active {
    color: #059669;
    font-weight: 800;
}

/* ==================== STATUS BADGE ==================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    border: 1px solid;
    white-space: nowrap;
}

.status-investigating {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.status-report {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde047;
}

.status-fa {
    background: #fed7aa;
    color: #9a3412;
    border-color: #fdba74;
}

.status-completed {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

/* ==================== BUTTON STYLES ==================== */
button {
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    border: none;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ==================== ANIMATIONS ==================== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== HEADER STYLES ==================== */
.header-shadow {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ==================== FORM STYLES ==================== */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #10b981;
    ring: 2px;
    ring-color: #10b981;
}

/* ==================== PAGINATION STYLES ==================== */
#pagination button {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #cbd5e1;
    background: white;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

#pagination button:hover:not(:disabled) {
    background: #d1fae5;
    border-color: #10b981;
}

#pagination button:disabled {
    background: #f1f5f9;
    color: #94a3b8;
}

/* ==================== KPI TAB TABLE STYLES ==================== */
#tab-stats table {
    width: 100% !important;
    max-width: 900px;
    margin: 0 auto !important;
    table-layout: auto !important;
}

#tab-stats table thead th {
    padding: 0.5rem !important;
    font-size: 0.7rem !important;
    line-height: 1.2;
    white-space: normal;
    word-wrap: break-word;
}

#tab-stats table tbody td {
    padding: 0.75rem 0.5rem !important;
    font-size: 0.875rem;
}

#tab-stats .bg-cyan-600 td {
    font-size: 1rem !important;
}

/* ==================== CARD STYLES ==================== */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.card-hover {
    transition: all 0.2s ease;
}

.card-hover:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* ==================== STATS CARD STYLES ==================== */
.stat-card {
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 2px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.stat-card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 640px) {
    .spinner {
        width: 40px;
        height: 40px;
    }
    
    #table-container {
        height: calc(100vh - 280px);
    }
    
    table {
        font-size: 0.75rem;
        min-width: 1200px;
    }
    
    table input {
        padding: 0.375rem;
        font-size: 0.75rem;
    }
    
    .stat-card-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    #table-container {
        height: calc(100vh - 250px);
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    button,
    .no-print,
    #search-input,
    #pagination,
    header button {
        display: none !important;
    }
    
    header {
        background: white !important;
        color: black !important;
        border-bottom: 2px solid #000;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    thead {
        display: table-header-group;
    }
    
    body {
        background: white;
        zoom: 1;
    }
}

/* ==================== UTILITY CLASSES ==================== */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transition-all {
    transition: all 0.2s ease;
}

.transition-colors {
    transition: color 0.2s ease, background-color 0.2s ease;
}

.transition-transform {
    transition: transform 0.2s ease;
}

/* ==================== HOVER EFFECTS ==================== */
.row-hover:hover {
    background: #f8fafc;
}

.cell-hover:hover {
    background: #f1f5f9;
}

/* ==================== LOADING STATE ==================== */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==================== TOOLTIP ==================== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #1e293b;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
}
