/* UAE Enterprise HRMS - Custom Styles */

:root {
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e9ecef;
    --primary-color: #0d6efd;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0;
}

/* Sidebar */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-inline-end: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
    inset-inline-start: 0;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.sidebar-header .sidebar-toggle {
    position: absolute;
    inset-inline-end: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.sidebar-brand {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

.sidebar-brand:hover {
    color: var(--primary-color);
}

.sidebar-user {
    padding: 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    background: #f8f9fa;
}

.sidebar-menu {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-item {
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
}

.sidebar-heading {
    padding: 0.9rem 1.15rem 0.4rem;
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9aa3af;
    list-style: none;
}

.sidebar-menu > .sidebar-heading:first-child {
    padding-top: 0.4rem;
}

[data-bs-theme="dark"] .sidebar-heading {
    color: #6c7480;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #495057;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    gap: 0.75rem;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: var(--primary-color);
    color: #ffffff;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-inline-start: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Cards */
.card {
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
}

.icon-box {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.min-width-0 {
    min-width: 0;
}

/* Tables */
.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-inline-start: 0;
    }
}

/* Global safety nets: nothing (image, canvas, or an odd fixed-width block)
   should be able to force the whole page to scroll sideways. Elements that
   genuinely need horizontal scroll (tables, the calendar grid) get their own
   local overflow-x container, which this does not interfere with. */
body {
    overflow-x: hidden;
}

img, canvas {
    max-width: 100%;
    height: auto;
}

/* Month-grid calendars (Tasks calendar, unified Calendar): fixed-height
   cells sized for desktop are too tall on a phone once 7 columns must
   share a narrow width, so shrink them and let the table-responsive
   wrapper handle any horizontal overflow that remains. */
@media (max-width: 575.98px) {
    .calendar-table td {
        height: 64px !important;
        min-width: 76px;
        padding: 0.25rem;
    }

    .calendar-table th {
        font-size: 0.7rem;
        padding: 0.35rem 0.2rem;
    }

    .calendar-table .small {
        font-size: 0.7rem;
    }
}

/* Avatar */
.avatar {
    font-weight: 600;
    font-size: 0.875rem;
}

/* Form Enhancements */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

/* Footer */
.main-content > .container-fluid {
    flex: 1;
}

.app-footer {
    border-top: 1px solid var(--sidebar-border);
}

/* Dashboard: welcome banner */
.dash-welcome {
    border-radius: 1rem;
    padding: 1.75rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(var(--bs-primary-rgb), 0.75) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.dash-welcome::after {
    content: '';
    position: absolute;
    inset-inline-end: -40px;
    top: -40px;
    width: 180px;
    height: 180px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.dash-welcome .dash-welcome-sub {
    color: rgba(255, 255, 255, 0.85);
}

.dash-welcome .btn-light {
    font-weight: 600;
}

/* Dashboard: stat cards */
.stat-card {
    border-radius: 1rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.08);
}

.stat-card .icon-box {
    width: 52px;
    height: 52px;
    border-radius: 0.85rem;
    font-size: 1.35rem;
}

.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

/* Dashboard: status chips (fixed palette, never themed) */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.status-chip .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-chip-good { background: rgba(12, 163, 12, 0.1); color: #0a7a0a; }
.status-chip-good .status-dot { background: #0ca30c; }
.status-chip-warning { background: rgba(250, 178, 25, 0.15); color: #8a5a00; }
.status-chip-warning .status-dot { background: #fab219; }
.status-chip-serious { background: rgba(236, 131, 90, 0.15); color: #9c4321; }
.status-chip-serious .status-dot { background: #ec835a; }
.status-chip-critical { background: rgba(208, 59, 59, 0.12); color: #d03b3b; }
.status-chip-critical .status-dot { background: #d03b3b; }

.dash-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #495057;
}

/* Dashboard: chart widgets */
.chart-container {
    position: relative;
    height: 260px;
}

.chart-container.chart-container-sm {
    height: 200px;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: #495057;
}

.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .chart-legend-item {
    color: #adb5bd;
}

/* Dark mode */
[data-bs-theme="dark"] {
    --sidebar-bg: #1a1d23;
    --sidebar-border: #2d3238;
}

[data-bs-theme="dark"] body {
    background-color: #12141a;
    color: #dee2e6;
}

[data-bs-theme="dark"] .sidebar-user {
    background: #20242b;
}

[data-bs-theme="dark"] .main-header {
    background: #1a1d23;
}

/* .text-dark is a fixed Bootstrap color that never inverts on its own —
   without this, the theme toggle, notification bell and profile buttons
   render black-on-black and effectively disappear in dark mode. */
[data-bs-theme="dark"] .main-header .text-dark {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .main-header h5 {
    color: #dee2e6;
}

[data-bs-theme="dark"] .sidebar-link {
    color: #adb5bd;
}

[data-bs-theme="dark"] .sidebar-link:hover,
[data-bs-theme="dark"] .sidebar-link.active {
    background: var(--primary-color);
    color: #ffffff;
}

[data-bs-theme="dark"] .app-footer {
    color: #8a919a;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.08);
}

[data-bs-theme="dark"] .card {
    background-color: #1a1d23;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}

/* Bootstrap's .bg-white / .bg-light utilities are fixed hex colors that
   ignore data-bs-theme; they're used app-wide for card-headers, so they
   need an explicit dark override rather than a per-page fix. */
[data-bs-theme="dark"] .bg-white {
    background-color: #1a1d23 !important;
    color: #dee2e6;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #20242b !important;
    color: #dee2e6;
}

[data-bs-theme="dark"] .card-header.bg-white,
[data-bs-theme="dark"] .card-header.bg-light {
    border-bottom-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .list-group-item {
    background-color: #1a1d23;
    color: #dee2e6;
    border-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .breadcrumb-item.active {
    color: #adb5bd;
}

[data-bs-theme="dark"] hr {
    border-color: var(--sidebar-border);
    opacity: 1;
}

[data-bs-theme="dark"] .nav-tabs {
    border-bottom-color: var(--sidebar-border);
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: #adb5bd;
}

[data-bs-theme="dark"] .stat-card .stat-label {
    color: #8a919a;
}

[data-bs-theme="dark"] .dash-section-title {
    color: #c3c8cd;
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td {
    background-color: #20242b;
    color: #dee2e6;
}

[data-bs-theme="dark"] .status-chip-good { background: rgba(12, 163, 12, 0.18); color: #4fd44f; }
[data-bs-theme="dark"] .status-chip-warning { background: rgba(250, 178, 25, 0.18); color: #fab219; }
[data-bs-theme="dark"] .status-chip-serious { background: rgba(236, 131, 90, 0.18); color: #ec835a; }
[data-bs-theme="dark"] .status-chip-critical { background: rgba(208, 59, 59, 0.2); color: #e66767; }

/* Attendance Records grid */
.att-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.82rem;
}

.att-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #495057;
}

.att-grid-table {
    font-size: 0.85rem;
    border-collapse: separate;
    border-spacing: 0;
}

.att-grid-table th, .att-grid-table td {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.att-emp-col {
    position: sticky;
    inset-inline-start: 0;
    background: var(--bs-body-bg, #fff);
    text-align: start !important;
    z-index: 2;
    min-width: 200px;
}

.att-weekend-col {
    background: rgba(108, 117, 125, 0.08);
}

.att-cell-link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    text-decoration: none;
    padding: 0.35rem 0.15rem;
    border-radius: 0.4rem;
    min-width: 34px;
}

.att-cell-link:hover {
    background: rgba(var(--bs-primary-rgb), 0.08);
}

.att-icon { font-size: 1rem; line-height: 1; }
.att-icon-present { color: #0ca30c; }
.att-icon-absent { color: #d03b3b; }
.att-icon-half { color: #fab219; font-weight: 700; font-size: 0.85rem; }
.att-icon-leave { color: #e0508a; }
.att-icon-holiday { color: #eda100; }
.att-icon-off { color: #adb5bd; }
.att-icon-future { color: #ced4da; }
.att-icon-not-added { color: #ced4da; }

.att-badges { display: flex; gap: 2px; }
.att-badge { font-size: 0.6rem; line-height: 1; }
.att-badge-late { color: #fab219; }
.att-badge-early { color: #d03b3b; }
.att-badge-ot { color: #2a78d6; }

[data-bs-theme="dark"] .att-emp-col {
    background: #1a1d23;
}

[data-bs-theme="dark"] .att-weekend-col {
    background: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .att-legend-item {
    color: #adb5bd;
}
