/* ==========================================================================
   1. CSS Custom Properties (Variables)
   ========================================================================== */
:root {
    /* Layout */
    --sidebar-width: 240px;
    --top-header-height: 60px;

    /* Typography */
    --smart-font: 'Inter', sans-serif;
    --text-color: #1e293b;

    /* Colors - Backgrounds */
    --primary-bg: #f3f4f6;
    --sidebar-bg: #0f172a;
    --sidebar-hover-bg: #1e293b;
    --card-header-bg: #fff;
    --table-header-bg: #f8fafc;
    --table-row-hover-bg: #f9fafb;
    --login-bg: #f3f4f6;
    --login-card-bg: #ffffff;
    --login-input-bg: #f9fafb;
    --user-dropdown-bg: #f9fafb;
    --user-dropdown-hover-bg: #f8f9fa;
    --profile-header-bg: #f4f6f8;
    --stripe-color: #e3f2fd;

    /* Colors - Text */
    --sidebar-text-color: #fff;
    --profile-detail-color: #374151;

    /* Colors - Status */
    --active-status-bg: #dcfce7;
    --active-status-color: #166534;
    --leave-status-bg: #fee2e2;
    --leave-status-color: #991b1b;
    --hold-status-bg: #fef3c7;
    --hold-status-color: #92400e;
    --paid-status-bg: #e0f7fa;
    --paid-status-color: #00838f;
    --pending-status-bg: #fff9e6;
    --pending-status-color: #ff8f00;
    --draft-status-bg: #e8eaf6;
    --draft-status-color: #3f51b5;

    /* Colors - Borders */
    --border-color: #4b5563;
    --sidebar-border-color: #1e293b;
    --card-header-border: #f1f5f9;
    --table-header-border: #e2e8f0;
    --table-row-border: #f1f5f9;
    --top-header-border: #e2e8f0;
    --profile-activity-border: #f3f4f6;
    --login-card-border: #e5e7eb;
    --login-input-border: #e5e7eb;
    --login-input-focus-border: #3b82f6;

    /* Colors - Accent */
    --login-logo-color: #1d4ed8;
    --profile-tab-active-color: #1d4ed8;
    --profile-tab-active-border: #1d4ed8;

    /* Effects */
    --card-radius: 6px;
}

/* ==========================================================================
   2. Global Styles & Resets
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--smart-font);
    background-color: var(--primary-bg);
    font-size: 1rem;
    overflow-x: hidden;
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    text-decoration: none;
}

ul,
ol {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ==========================================================================
   3. Utility Classes
   ========================================================================== */

/* Spacing */
.tiny-padding {
    padding: 7px !important;
}

.small-padding {
    padding: 10px !important;
}

.tiny-margin {
    margin: 5px !important;
}

.small-margin {
    margin: 10px !important;
}

/* Typography */
.text-tiny {
    font-size: 0.9rem;
}

.text-micro {
    font-size: 0.75rem;
}

.text-small {
    font-size: 0.95rem;
}

.text-normal {
    font-size: 1rem;
}

.text-large {
    font-size: 1.1rem;
}

.ls-1 {
    letter-spacing: 0.5px;
}

.ls-2 {
    letter-spacing: 1px;
}

.line-height-1 {
    line-height: 1.2;
}

.line-height-2 {
    line-height: 1.5;
}

.font-weight-500 {
    font-weight: 500;
}

.font-weight-600 {
    font-weight: 600;
}

.font-weight-700 {
    font-weight: 700;
}

.text-uppercase {
    text-transform: uppercase;
}

/* Display & Layout */
.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.flex-column {
    flex-direction: column;
}

/* Colors & Backgrounds */
.bg-white {
    background-color: #fff;
}

.bg-transparent {
    background-color: transparent;
}

/* ==========================================================================
   4. Layout Components
   ========================================================================== */

/* --- Main Container --- */
#content {
    margin-left: var(--sidebar-width);
    padding: 13px;
    transition: all 0.2s;
    min-height: 100vh;
}

/* --- Sidebar --- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text-color);
    transition: all 0.3s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

#sidebar .brand {
    padding: 12px 15px;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--sidebar-border-color);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    min-height: 60px;
}

#sidebar ul.components {
    padding: 11px 0;
    flex: 1;
}

#sidebar ul li {
    padding: 2px 8px;
}

#sidebar ul li a {
    padding: 10px 15px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: 500;
}

#sidebar ul li a:hover,
#sidebar ul li a.active {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-color);
    transform: translateX(3px);
}

#sidebar ul li a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

/* --- Topbar --- */
.top-header {
    height: var(--top-header-height);
    border-bottom: 1px solid var(--top-header-border);
    background-color: #fff;
    position: sticky;
    top: 0;
    z-index: 990;
}

.top-icon-btn {
    width: 34px;
    height: 34px;
    line-height: 1;
    position: relative;
    padding: 0;
    font-size: 0.8rem;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}

.top-icon-btn:hover {
    background-color: #f3f4f6;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    padding: 6px 12px;
    font-size: 0.55rem;
    border: 1px solid white;
    background-color: #dc2626;
    color: white;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* User Dropdown */
.user-dropdown-toggle {
    transition: background-color 0.2s;
    border-radius: 50px;
    padding: 4px 8px 4px 4px !important;
    border: none;
    background: transparent;
    cursor: pointer;
}

.user-dropdown-toggle:hover {
    background-color: var(--user-dropdown-hover-bg);
}

.user-avatar {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
}

.user-dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    border: 1px solid #e5e7eb;
    margin-top: 8px;
}

.user-info-header {
    padding: 8px 16px;
    cursor: default;
    background-color: var(--user-dropdown-bg);
    border-bottom: 1px solid #e5e7eb;
}

.user-dropdown-menu .dropdown-item {
    padding: 8px 16px;
    transition: background-color 0.15s;
    font-size: 0.85rem;
    color: #374151;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.user-dropdown-menu .dropdown-item:hover {
    background-color: #f3f4f6;
}

.user-dropdown-menu .dropdown-item i {
    width: 18px;
    margin-right: 8px;
}

.user-dropdown-menu .dropdown-divider {
    margin: 4px 0;
    height: 1px;
    background-color: #e5e7eb;
    border: none;
}

/* ==========================================================================
   5. UI Components
   ========================================================================== */

/* --- Cards --- */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    background: white;
    margin-bottom: 16px;
}

.card-header {
    background: var(--card-header-bg);
    border-bottom: 1px solid var(--card-header-border);
    padding: 12px 16px;
    font-weight: 600;
}

.card-body {
    padding: 22px;
}

.stat-card {
    border: none;
    border-radius: var(--card-radius);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stat-card .card-body {
    padding: 16px 20px;
}

.stat-card h6 {
    font-size: 0.7rem;
    opacity: 0.9;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.stat-card i {
    font-size: 1.7rem;
    opacity: 0.25;
    position: absolute;
    right: 10px;
    bottom: 10px;
}

/* Card Color Classes */
.bg-c-1 {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.bg-c-2 {
    background: linear-gradient(135deg, #059669, #10b981);
}

.bg-c-3 {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.bg-c-4 {
    background: linear-gradient(135deg, #d97706, #f59e0b);
}

.bg-c-5 {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}

.bg-c-6 {
    background: linear-gradient(135deg, #0891b2, #06b6d4);
}

.bg-c-7 {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
}

.bg-c-8 {
    background: linear-gradient(135deg, #475569, #64748b);
}

/* --- Tables --- */
.card-table {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    background: white;
}

.card-table .card-header {
    background: var(--card-header-bg);
    border-bottom: 1px solid var(--card-header-border);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

table.dataTable {
    font-size: 0.75rem !important;
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 5px !important;
}

table.dataTable thead th {
    background-color: var(--table-header-bg);
    border-bottom: 2px solid var(--table-header-border);
    font-weight: 700;
    padding: 3px 3px !important;
    color: #475569;
    text-transform: uppercase;
    vertical-align: middle;
}

table.dataTable tbody td {
    padding: 3px 2px !important;
    vertical-align: middle;
    border-bottom: 1px solid var(--table-row-border);
    color: #334155;
}



/* --- Status Badges --- */
.status-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
    min-width: 60px;
    text-align: center;
    border: 1px solid transparent;
}

.status-active {
    background-color: var(--active-status-bg);
    color: var(--active-status-color);
    border-color: var(--active-status-color);
}

.status-leave {
    background-color: var(--leave-status-bg);
    color: var(--leave-status-color);
    border-color: var(--leave-status-color);
}

.status-hold {
    background-color: var(--hold-status-bg);
    color: var(--hold-status-color);
    border-color: var(--hold-status-color);
}

.status-paid {
    background-color: var(--paid-status-bg);
    color: var(--paid-status-color);
    border-color: var(--paid-status-color);
}

.status-pending {
    background-color: var(--pending-status-bg);
    color: var(--pending-status-color);
    border-color: var(--pending-status-color);
}

.status-draft {
    background-color: var(--draft-status-bg);
    color: var(--draft-status-color);
    border-color: var(--draft-status-color);
}

/* --- Buttons --- */
.btn {
    padding: 8px 15px;
    font-size: 0.9rem;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-sm {
    padding: 6px 11px;
    font-size: 0.85rem;
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-outline-primary {
    background-color: transparent;
    color: #3b82f6;
    border-color: #3b82f6;
}

.btn-outline-primary:hover {
    background-color: #3b82f6;
    color: white;
}

/* --- Forms --- */
.form-control {
    padding: 8px 11px;
    font-size: 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background-color: white;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control-sm {
    padding: 4px 6px;
    font-size: 0.7rem;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: #374151;
}

/* ==========================================================================
   6. Page-Specific Styles
   ========================================================================== */

/* --- Profile Page --- */
.profile-header-card {
    border-radius: 12px;
    background: linear-gradient(135deg, var(--profile-header-bg) 0%, #ffffff 100%);
    position: relative;
    overflow: hidden;
    padding: 24px;
}

.profile-avatar-container {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: 16px;
}

.profile-avatar {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
}

.profile-pic-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
    background-color: #3b82f6;
    color: white;
    border: 2px solid white;
    cursor: pointer;
}

/* Profile Tabs */
.profile-tabs {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.profile-tabs .nav {
    display: flex;
    gap: 8px;
}

.profile-tabs .nav-link {
    font-size: 0.85rem;
    padding: 10px 15px;
    color: #4b5563;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-tabs .nav-link:hover {
    color: #1d4ed8;
}

.profile-tabs .nav-link.active {
    color: var(--profile-tab-active-color);
    border-bottom: 3px solid var(--profile-tab-active-border);
    background-color: transparent;
    font-weight: 600;
}

/* Detail List */
.detail-item {
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--profile-detail-color);
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.detail-item strong {
    color: #1f2937;
    min-width: 120px;
}

.activity-list .list-group-item {
    padding: 12px 0;
    border-color: var(--profile-activity-border);
    border-bottom: 1px solid var(--profile-activity-border);
    background: transparent;
}

.activity-list .list-group-item:last-child {
    border-bottom: none;
}

/* --- Login Page --- */
.login-page-body {
    background-color: var(--login-bg);
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="p" width="80" height="80" patternUnits="userSpaceOnUse"><path d="M0 40h80M40 0v80" stroke="%23e5e7eb" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23p)"/></svg>');
    background-size: 80px 80px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    max-width: 400px;
    width: 100%;
    background-color: var(--login-card-bg);
    border-radius: 12px;
    border: 1px solid var(--login-card-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 32px;
}

.login-card .fa-hard-hat {
    color: var(--login-logo-color);
    font-size: 2rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-title {
    text-align: center;
    margin-bottom: 24px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
}

/* Smart Input Group Styling */
.smart-input-group {
    margin-bottom: 16px;
}

.smart-input-group .input-group {
    display: flex;
}

.smart-input-group .input-group-text {
    background-color: var(--login-input-bg);
    border: 1px solid var(--login-input-border);
    border-right: none;
    padding: 8px 12px;
    color: #9ca3af;
    border-radius: 4px 0 0 4px;
}

.smart-input-group .form-control {
    border: 1px solid var(--login-input-border);
    border-left: none;
    border-radius: 0 4px 4px 0;
    padding: 10px 13px;
    background-color: white;
    flex: 1;
}

.smart-input-group .form-control:focus {
    border-color: var(--login-input-focus-border);
    z-index: 2;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.toggle-password {
    background-color: var(--login-input-bg);
    border: 1px solid var(--login-input-border);
    border-left: none;
    border-radius: 0 4px 4px 0;
    padding: 8px 12px;
    cursor: pointer;
    color: #6b7280;
}

.toggle-password:hover {
    background-color: #f3f4f6;
}

.login-btn {
    padding: 10px 0;
    font-size: 1rem;
    letter-spacing: 0.5px;
    width: 100%;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 600;
}

.login-btn:hover {
    background-color: #2563eb;
}

.login-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ==========================================================================
   7. Responsive Design
   ========================================================================== */

/* Tablet (768px and down) */
@media (max-width: 768px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        width: var(--sidebar-width);
    }



    #sidebar.active {
        margin-left: 0;
    }

    #content {
        margin-left: 0;
        padding: 8px;
    }

    #content.active {
        margin-left: var(--sidebar-width);
    }

    .stat-card {
        margin-bottom: 8px;
    }

    .profile-header-card {
        padding: 16px;
    }

    .profile-tabs .nav {
        flex-wrap: wrap;
    }

    .card-table .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Mobile (576px and down) */
@media (max-width: 576px) {
    body {
        font-size: 0.75rem;
    }

    .login-card {
        padding: 24px 16px;
    }

    .profile-avatar-container {
        width: 70px;
        height: 70px;
    }

    .profile-avatar {
        width: 70px;
        height: 70px;
    }

    .detail-item {
        flex-direction: column;
        gap: 2px;
    }

    .detail-item strong {
        min-width: auto;
    }
}

/* ==========================================================================
   8. Print Styles
   ========================================================================== */
@media print {
    @page {
        size: A4 landscape;
        margin: 5mm;
    }

    body {
        background: white !important;
        font-size: 9pt !important;
        color: #000 !important;
    }

    /* Hide non-essential elements */
    #sidebar,
    .top-header,
    .btn,
    .dropdown,
    .dataTables_filter,
    .dt-buttons,
    .dataTables_info,
    .dataTables_paginate,
    .action-col,
    .no-print {
        display: none !important;
    }

    /* Adjust layout for print */
    #content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Table styling for print */
    .card-table {
        box-shadow: none !important;
        border: 1px solid #000 !important;
        margin: 0 !important;
    }

    .card-header {
        display: none !important;
    }

    table.dataTable {
        width: 100% !important;
        border-collapse: collapse !important;
        border: 2px solid #333 !important;
    }

    table.dataTable th,
    table.dataTable td {
        border: 1px solid #000 !important;
        padding: 5px 5px !important;
        font-size: 11pt !important;
        color: #000 !important;
    }

    table.dataTable thead th {
        background-color: #e5e7eb !important;
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
        font-weight: 700 !important;
    }

    /* Striped rows for readability */
    table.dataTable tbody tr:nth-of-type(odd) {
        background-color: #ffffff !important;
    }

    table.dataTable tbody tr:nth-of-type(even) {
        background-color: var(--stripe-color) !important;
    }

    /* Status badges with borders for print */
    .status-badge {
        border: 1px solid !important;
        padding: 1px 4px !important;
    }

    .status-active {
        background-color: var(--active-status-bg) !important;
        color: var(--active-status-color) !important;
        border-color: var(--active-status-color) !important;
    }

    .status-leave {
        background-color: var(--leave-status-bg) !important;
        color: var(--leave-status-color) !important;
        border-color: var(--leave-status-color) !important;
    }

    .status-hold {
        background-color: var(--hold-status-bg) !important;
        color: var(--hold-status-color) !important;
        border-color: var(--hold-status-color) !important;
    }

    .status-paid {
        background-color: var(--paid-status-bg) !important;
        color: var(--paid-status-color) !important;
        border-color: var(--paid-status-color) !important;
    }

    .status-pending {
        background-color: var(--pending-status-bg) !important;
        color: var(--pending-status-color) !important;
        border-color: var(--pending-status-color) !important;
    }

    .status-draft {
        background-color: var(--draft-status-bg) !important;
        color: var(--draft-status-color) !important;
        border-color: var(--draft-status-color) !important;
    }

    /* Footer styling */
    tfoot {
        display: table-row-group !important;
        border-top: 2px solid #000 !important;
    }

    tfoot th {
        background-color: #cbd5e1 !important;
        color: #000 !important;
        font-weight: 900 !important;
        font-size: 10pt !important;
    }
}