:root {
    --primary: #2c3e50;
    --secondary: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --light: #ecf0f1;
    --border: #bdc3c7;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    margin: 0;
    background-color: #f4f7f6;
    color: #333;
}

/* Top Navigation */
.top-nav {
    background-color: var(--primary);
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    align-items: center;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    transition: 0.3s;
    white-space: nowrap;
}

.nav-btn:hover,
.nav-btn.active {
    background-color: var(--secondary);
    font-weight: bold;
}

.sub-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.sub-tab-btn {
    background: #eef3f2;
    color: #2c3e50;
}

.sub-tab-btn.active {
    background: var(--secondary);
    color: white;
    font-weight: bold;
}

.daily-panel {
    display: none;
}

.daily-panel.active {
    display: block;
}

.main-panel {
    display: none;
}

.main-panel.active {
    display: block;
}

.main-panel {
    display: none;
}

.main-panel.active {
    display: block;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable::after {
    content: " ⇅";
    color: #7f8c8d;
    font-size: 12px;
}

th.sort-asc::after {
    content: " ↑";
    color: var(--secondary);
}

th.sort-desc::after {
    content: " ↓";
    color: var(--secondary);
}

.company-title {
    color: white;
    margin-left: auto;
    font-weight: bold;
    font-size: 18px;
}

/* Main Layout */
.content {
    padding: 20px;
}

.tab-content {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.tab-content.active {
    display: block;
}

/* Forms & Filters */
.form-group,
.filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 20px;
    background: #fdfdfd;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 5px;
}

.form-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
    flex: 1;
    min-width: 150px;
}

.form-control label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #333;
}


.form-control input,
.form-control select {
    width: 100%;
    box-sizing: border-box;
}

input,
select,
button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
}

button {
    background-color: var(--secondary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background-color: #219653;
}

.btn-danger {
    background-color: var(--danger);
}

.btn-warning {
    background-color: var(--warning);
    color: #fff;
}

.state-present {
    color: #1b5e20;
    background: #e8f5e9;
    font-weight: 700;
}

.state-absent {
    color: #ffffff;
    background: #ff0000;
    font-weight: 700;
}

.state-annual {
    color: #ffffff;
    background: #e67e22;
    font-weight: 700;
}

.state-holiday {
    color: #1565c0;
    background: #e3f2fd;
    font-weight: 700;
}

/* دعم الألوان عند الطباعة */
@media print {
    .state-present,
    .state-absent,
    .state-annual,
    .state-holiday {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .state-absent {
        background: #ff0000 !important;
        color: #ffffff !important;
    }

    .state-annual {
        background: #e67e22 !important;
        color: #ffffff !important;
    }

    .state-present {
        background: #e8f5e9 !important;
        color: #1b5e20 !important;
    }

    .state-holiday {
        background: #e3f2fd !important;
        color: #1565c0 !important;
    }

    /* ضمان أن خط الجداول عند الطباعة بوزن 700 */
    table,
    table th,
    table td {
        font-weight: 800 !important;
    }
}

/* منع التفاف النص في عمودي الاسم والفرع */
.employee-name,
.branch-name {
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
}
.employee-name {
    min-width: 120px;
}
.branch-name {
    min-width: 100px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 12px;
    font-weight: 800;  
}

th,
td {
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border);
}

th {
    background-color: #dcedc8;
    color: var(--primary);
}

tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.table-wrapper {
    max-height: 60vh;
    overflow: auto;
    border: 1px solid #dfe3e6;
    border-radius: 8px;
}

.table-wrapper table {
    margin-top: 0;
}

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}

/* === تعديل: إخفاء صف الشعار في الشاشة العادية، يظهر فقط عند الطباعة === */
thead tr.print-header-row {
    display: none;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .top-nav,
    .filters,
    .form-group,
    button,
    .no-print,
    td:last-child,
    th:last-child {
        display: none !important;
    }

    .content,
    .tab-content {
        padding: 0;
        box-shadow: none;
        display: block !important;
    }

    /* Only main tab prints */
    .tab-content {
        display: none !important;
    }

    #tab-main {
        display: block !important;
    }

    #tab-employees,
    #tab-branches,
    #tab-users,
    #tab-settings,
    #tab-daily,
    #tab-archive {
        display: none !important;
    }

    /* === تعديل: إخفاء printHeader الأصلي (لم يعد مستخدماً في الطباعة) === */
    /* الكود الأصلي: كان يظهر printHeader خارج الجدول */
    #printHeader {
        display: none !important;
    }

    /* === تعديل: إظهار صف الشعار (print-header-row) عند الطباعة فقط === */
    /* الصف مخفي في الشاشة (display:none) ويظهر هنا عند الطباعة */
    thead tr.print-header-row {
        display: table-row !important;
    }
    /* جعل حاوية الشعار والصور بعرض كامل عند الطباعة */
    thead tr.print-header-row td {
        border: none !important;
        padding: 10px 0 !important;
    }
    thead tr.print-header-row td img {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        object-fit: fill !important;
    }

    table {
        border: 2px solid black;
    }

    th,
    td {
        border: 1px solid black;
        padding: 6px;
    }

    /* Ensure full table prints (not clipped by scrolling containers) */
    .table-wrapper {
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
    }

    /* Repeat the table header on each printed page */
    thead {
        display: table-header-group !important;
    }

    /* === تعديل: ضمان أن صف الشعار الممتد (print-header-row) يتكرر في كل صفحة === */
    thead tr.print-header-row {
        display: table-row;
    }

    /* Disable sticky positioning for print so header repeats normally */
    table thead th {
        position: static !important;
        top: auto !important;
        z-index: 3;
    }

    /* Avoid breaking rows across pages when possible */
    tr, td {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* منع التفاف النص في عمودي الاسم والفرع عند الطباعة */
    .employee-name,
    .branch-name {
        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }
    .employee-name { min-width: 120px; }
    .branch-name { min-width: 100px; }
}

/* Print helper: hide everything except the print area when printing */
#tageepPrintArea { display: none; }
@media print {
    body.printing > * { display: none !important; }
    #tageepPrintArea { display: block !important; width: 100%; }
    #tageepPrintArea table { width: 100%; border-collapse: collapse; }
    /* === تعديل: جعل الشعار داخل thead بعرض كامل عند الطباعة === */
    #tageepPrintArea .print-header-row td div:first-child {
        width: 90%;
    }
    #tageepPrintArea .print-header-row td img {
        width: 90% !important;
        max-height: 150px;
        object-fit: contain;
    }
}

#printHeader {
    display: none;
    max-width: 90%;

}

#bootScreen,
#licenseScreen,
#loginScreen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#bootScreen {
    display: flex;
    background: #f4f7f6;
    color: var(--primary);
}

#licenseScreen,
#loginScreen {
    display: none;
}

.boot-card {
    background: #fff;
    border: 1px solid #dfe3e6;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 22px 32px;
    text-align: center;
    min-width: 240px;
}

.boot-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.boot-text {
    color: #607d8b;
}

.login-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 100%;
    text-align: center;
    direction: rtl;
}

.login-header h2 {
    margin: 0 0 20px;
    font-size: 22px;
    color: var(--primary);
}

.login-marquee {
    margin-bottom: 15px;
    color: white;
    background: var(--primary);
    padding: 10px;
    border-radius: 6px;
    animation: marquee 10s linear infinite;
    overflow: hidden;
    white-space: nowrap;
}

@keyframes marquee {
    0% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(-100%);
    }
}

.login-body .form-control {
    margin-bottom: 15px;
    text-align: right;
}

.login-body input[type="text"],
.login-body input[type="password"] {
    width: 100%;
}

.login-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.login-actions button {
    flex: 1;
}

.license-note {
    color: #666;
    line-height: 1.7;
    margin: 8px 0 18px;
}

#appRoot {
    display: none;
}

/* CSS للقوائم القابلة للبحث (Searchable Select) */
.searchable-select-input {
    cursor: pointer;
    background: #fff;
}
.searchable-select-input:focus {
    outline: none;
    border-color: #27ae60 !important;
    box-shadow: 0 0 4px rgba(39, 174, 96, 0.3);
}
.searchable-select-item:first-child {
    border-radius: 0 0 4px 4px;
}
.searchable-select-item:hover {
    background: #e8f0fe !important;
}
.searchable-select-item.selected {
    background: #dcedc8 !important;
    font-weight: bold;
}

/* تذييل الطباعة - التوقيعات (يظهر في صف واحد مع فاصل | بينهم) */
.print-footer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    direction: rtl;
}
.print-footer .signature {
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 10px;
    white-space: nowrap;
    position: relative;
}
.print-footer .signature:not(:last-child)::after {
    content: "|";
    margin-right: 15px;
    color: #333;
    font-weight: normal;
}

/* تذييل متكرر في الطباعة داخل tfoot */
.print-footer-row {
    display: none;
}
@media print {
    .print-footer-row {
        display: table-footer-group !important;
    }
    .print-footer-row td {
        border: none !important;
        padding: 15px 5px 5px 5px !important;
        font-weight: 800;
    }
    .print-footer {
        display: flex !important;
        justify-content: space-around !important;
        width: 100% !important;
    }
    .print-footer .signature {
        font-size: 10pt !important;
        border-top: 1px solid #000 !important;
        padding-top: 6px !important;
    }
    .print-footer .signature:not(:last-child)::after {
        content: "|" !important;
        margin-right: 15px !important;
        color: #333 !important;
        font-weight: normal !important;
    }
}

/* تحسين الطباعة - خطوط واضحة */
@media print {
    body {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    table {
        font-size: 10pt !important;
    }
    th, td {
        padding: 4pt 5pt !important;
    }
}
