/* =====================================================
   Traders Junction Attendance System
   Optimized Global CSS
===================================================== */


/* =========================
   RESET
========================= */

*{
    box-sizing:border-box;
}


html,
body{

    margin:0;
    padding:0;

    width:100%;

}


body{

    font-family:"Segoe UI", Arial, sans-serif;

    background:#f5f7fb;

    color:#1f2937;

}



/* =========================
   TOPBAR
========================= */


.topbar{

    position:fixed;

    top:0;

    left:0;

    width:100%;

    height:60px;

    background:#111827;

    color:white;

    display:flex;

    align-items:center;

    justify-content:space-between;

    padding:0 20px;

    z-index:3000;

}



/* LEFT SIDE */


.top-left{

    display:flex;

    align-items:center;

    height:60px;

    gap:15px;

}



.menu-btn{

    background:none;

    border:none;

    color:white;

    font-size:28px;

    width:35px;

    height:35px;

    display:flex;

    align-items:center;

    justify-content:center;

    cursor:pointer;

    padding:0;

}



.system-title{

    font-size:20px;

    font-weight:600;

    white-space:nowrap;

}



/* RIGHT SIDE */


.top-user{

    display:flex;

    align-items:center;

    gap:15px;

}



.admin-name{

    color:white;

    font-size:14px;

}



.logout-btn{

    background:#dc2626;

    color:white;

    padding:8px 15px;

    border-radius:6px;

    text-decoration:none;

    font-size:14px;

}



.logout-btn:hover{

    background:#b91c1c;

}



/* =========================
   SIDEBAR
========================= */


.sidebar{

    position:fixed;

    top:60px;

    left:-260px;

    width:260px;

    height:calc(100vh - 60px);

    background:white;

    box-shadow:3px 0 15px rgba(0,0,0,.2);

    transition:.3s ease;

    z-index:2500;

    padding-top:20px;

}



.sidebar.active{

    left:0;

}



.sidebar h3{

    padding:20px;

    margin:0;

    color:#111827;

}



.sidebar a{

    display:block;

    padding:15px 25px;

    color:#374151;

    text-decoration:none;

    font-size:15px;

}



.sidebar a:hover{

    background:#2563eb;

    color:white;

}



/* =========================
   OVERLAY
========================= */


#overlay{

    position:fixed;

    top:60px;

    left:0;

    width:100%;

    height:calc(100vh - 60px);

    background:rgba(0,0,0,.4);

    display:none;

    z-index:2000;

}



#overlay.show{

    display:block;

}


/* =========================
   MAIN CONTENT
========================= */


.main{

    width:100%;

    max-width:none;

    margin:0;

    padding:30px;

    padding-top:90px;

}



/* =========================
   PAGE CARD
========================= */


.page-card{

    width:100%;

    background:white;

    padding:30px;

    border-radius:12px;

    box-shadow:0 5px 20px rgba(0,0,0,.06);
}



/* =========================
   DASHBOARD CARDS
========================= */


.cards{

    display:grid;

    grid-template-columns:repeat(auto-fit,minmax(220px,1fr));

    gap:20px;

    width:100%;

}



.card{

    background:white;

    padding:25px;

    border-radius:12px;

    box-shadow:0 5px 20px rgba(0,0,0,.06);

}



.card-title{

    color:#6b7280;

    font-size:15px;

}



.card-number{

    font-size:36px;

    font-weight:700;

    margin-top:10px;

}



/* =========================
   BUTTONS
========================= */


.btn{

    display:inline-block;

    padding:12px 22px;

    border-radius:8px;

    background:#2563eb;

    color:white;

    text-decoration:none;

    border:none;

    cursor:pointer;

    margin-right:10px;

    font-size:14px;

}



.btn:hover{

    opacity:.9;

}



/* =========================
   TABLES
========================= */


table{

    width:100%;

    background:white;

    border-collapse:collapse;

    margin-top:20px;

}



table th{

    background:#111827;

    color:white;

    padding:12px;

    text-align:left;

}



table td{

    padding:12px;

    border-bottom:1px solid #e5e7eb;

}



/* =========================
   FORMS
========================= */


input,
select,
textarea{


    width:100%;

    padding:12px;

    border:1px solid #d1d5db;

    border-radius:7px;

    margin-top:5px;

    font-size:14px;

}



label{

    font-weight:600;

}



.form-group{

    margin-bottom:15px;

}



/* =========================
   EMPLOYEE ACTION BUTTONS
========================= */


.action-view,
.action-edit,
.action-danger,
.action-success{


    display:inline-block;

    padding:6px 12px;

    border-radius:6px;

    text-decoration:none;

    color:white !important;

    font-size:13px;

    margin-right:5px;

}



.action-view{

    background:#0891b2;

}



.action-edit{

    background:#2563eb;

}



.action-danger{

    background:#dc2626;

}



.action-success{

    background:#16a34a;

}



.action-view:hover,
.action-edit:hover,
.action-danger:hover,
.action-success:hover{

    opacity:.85;

}



/* =========================
   STATUS BADGES
========================= */


.status-active,
.status-inactive{

    font-weight:600;

    font-size:14px;

}



.status-active{

    color:#16a34a;

}



.status-inactive{

    color:#dc2626;

}


/* =========================
   ATTENDANCE TABLE
========================= */

.table-responsive{
    width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    display:block;
    -webkit-overflow-scrolling:touch;
    border:1px solid #e5e7eb; /* optional, replaces the red debug border */
}

.attendance-table{
    width:1800px;
    min-width:1800px;
    border-collapse:collapse;
}

.attendance-table th,
.attendance-table td{

    padding:12px;

    white-space:nowrap;

    vertical-align:middle;

}


.attendance-table input{

    width:200px;

}


.attendance-table select{

    width:auto;

}



/* Arrival Time Box */


.arrival-box{

    display:flex;

    align-items:center;

    gap:5px;

    flex-wrap:nowrap;

}



.arrival-box select{

    width:auto;

    min-width:80px;

    padding:8px;

    margin:0;

}



/* Status Dropdown */


.status-select{

    width:120px;

}



/* Attendance Inputs */


.absence-input,
.late-input{

    width:200px;

    padding:8px;

}



/* Late Preview */


.late-preview{

    font-size:12px;

    margin-top:5px;

    font-weight:600;

    white-space:nowrap;

}



/* =========================
   PROFILE / INFORMATION
========================= */


.page-card h2{

    margin-top:0;

}



.page-card h3{

    margin-top:30px;

    color:#111827;

}



.page-card p{

    line-height:1.7;

}



/* =========================
   SMALL TEXT
========================= */


small{

    color:#6b7280;

}



/* =========================
   RESPONSIVE DESIGN
========================= */


@media(max-width:768px){


    .system-title{

        font-size:16px;

    }



    .admin-name{

        display:none;

    }



    .main{

        padding:20px;

        padding-top:80px;

    }



    .cards{

        grid-template-columns:1fr;

    }



    table{

        display:block;

        overflow-x:auto;

        white-space:nowrap;

    }



    .topbar{

        padding:0 10px;

    }



}



@media(max-width:480px){


    .menu-btn{

        font-size:24px;

    }



    .logout-btn{

        padding:7px 10px;

        font-size:12px;

    }



    .page-card{

        padding:15px;

    }


}


.success-message{

background:#d4edda;
color:#155724;
padding:12px;
border-radius:6px;
margin-bottom:20px;
font-weight:bold;

}

.attendance-table tr {
    height: 55px;
}

.attendance-table td {
    padding: 12px 8px;
    vertical-align: middle;
}

.weekend-row td {
    background:#fff9e6;
    height:55px;
}


.page-header{
    margin-bottom:20px;
}


.info-card,
.filter-card,
.summary{
    background:#ffffff;
    border-radius:16px;
    padding:20px;
    margin-bottom:20px;
    box-shadow:0 5px 20px rgba(0,0,0,0.06);
}


.info-card h3,
.filter-card h3,
.summary h3{
    margin-top:0;
    color:#0B1423;
}


.info-card p{
    margin:10px 0;
    font-size:15px;
}


.filter-card label{
    display:block;
    margin-bottom:6px;
    font-weight:600;
}


.filter-card input{
    width:100%;
    padding:10px;
    border:1px solid #ddd;
    border-radius:8px;
    margin-bottom:15px;
}


.filter-card .btn{
    background:#2563eb;
    color:white;
    border:none;
    padding:10px 18px;
    border-radius:8px;
    cursor:pointer;
}

/* =========================
   ATTENDANCE HISTORY TABLE
========================= */


.attendance-history-table{

    width:100%;

    border-collapse:collapse;

}


.attendance-history-table th{

    background:#111827;

    color:white;

    padding:12px;

    text-align:left;

}


.attendance-history-table td{

    padding:12px;

    border-bottom:1px solid #e5e7eb;

    white-space:nowrap;

}


/* =========================
   ATTENDANCE STATUS BADGES
========================= */


.status-present,
.status-absent,
.status-offday,
.status-sandwich{

    display:inline-block;

    padding:5px 10px;

    border-radius:20px;

    font-size:12px;

    font-weight:600;

}



.status-present{

    background:#dcfce7;

    color:#166534;

}



.status-absent{

    background:#fee2e2;

    color:#991b1b;

}



.status-offday{

    background:#fef9c3;

    color:#854d0e;

}



.status-sandwich{

    background:#ffedd5;

    color:#9a3412;

}



.status-reason{

    display:block;

    margin-top:5px;

    font-size:12px;

    color:#6b7280;

}


/* =========================
   ATTENDANCE TABLE UX
========================= */


table tr:nth-child(even) td{

    background:#fafafa;

}



table tbody tr:hover td{

    background:#f1f5f9;

}



table th{

    position:sticky;

    top:0;

    z-index:10;

}



table td{

    vertical-align:middle;

}



.status-present,
.status-absent,
.status-offday,
.status-sandwich{

    white-space:nowrap;

}


/* =========================
   ATTENDANCE SUMMARY CARDS
========================= */


.summary-cards{

    display:grid;

    grid-template-columns:
    repeat(auto-fit,minmax(160px,1fr));

    gap:15px;

}



.summary-box{

    background:white;

    padding:18px;

    border-radius:12px;

    box-shadow:0 4px 15px rgba(0,0,0,.05);

}



.summary-box span{

    display:block;

    font-size:13px;

    color:#6b7280;

    margin-bottom:10px;

}



.summary-box strong{

    font-size:28px;

    color:#111827;

}



.present-box strong{

    color:#16a34a;

}



.absent-box strong{

    color:#dc2626;

}



.late-box strong{

    color:#ea580c;

}



.rate-box strong{

    color:#2563eb;

}

@page {
    margin: 15mm;
}


@media print {

    /* Hide unnecessary elements */
    .topbar,
    .menu-btn,
    .btn,
    button,
    .filter-card {
        display: none !important;
    }


    /* Page background */
    body {
        background: #fff !important;
    }


    /* Remove screen styling */
    .main,
    .page-card {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }


    .info-card {
        box-shadow: none !important;
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 10px !important;
    }


    /* Employee information should stay together */
    .employee-information {
        page-break-inside: avoid;
    }


    /* Attendance summary */
    .attendance-summary {
        height: auto !important;
        min-height: 0 !important;
        page-break-inside: avoid;
        margin-top: 10px !important;
    }


    /* Summary cards print layout */
    .summary-container {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
    }


    /* Attendance table */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }


    tr {
        page-break-inside: avoid;
    }


    thead {
        display: table-header-group;
    }


    .attendance-records {
        page-break-before: auto;
    }
    .summary-container {
    page-break-inside: avoid !important;
}

.summary-container {
    page-break-inside: avoid !important;
}


.attendance-records {
    margin-top:15px !important;
}

}

/* Clickable employee names */
a.emp-link{
    color:inherit;
    text-decoration:none;
    border-bottom:1px dotted currentColor;
}
a.emp-link:hover{
    color:#2d63ea;
    border-bottom-style:solid;
}


/* =========================================================
   UI REFRESH - compact forms + date pickers
   (appended last so it overrides the older form rules)
========================================================= */

input,
select,
textarea{
    padding:8px 10px;
    margin-top:4px;
}

/* date / month / time boxes: small, pointer cursor, whole box is clickable */
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="datetime-local"]{
    width:auto;
    min-width:150px;
    max-width:200px;
    padding:7px 10px;
    cursor:pointer;
}

.filter-card input[type="date"],
.filter-card input[type="month"],
.filter-card input[type="time"]{
    width:auto;
    margin-bottom:0;
}

/* keep long forms from stretching across the whole screen */
.form-group input,
.form-group select,
.form-group textarea{
    max-width:420px;
}

.form-group{
    margin-bottom:12px;
}

/* forms that are just "label + date + button": put them on one line */
form:has(> input[type="date"]):not(:has(table)):not(:has(.emp-picker)),
form:has(> input[type="month"]):not(:has(table)):not(:has(.emp-picker)){
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:8px 12px;
}

form:has(> input[type="date"]):not(:has(table)):not(:has(.emp-picker)) > label,
form:has(> input[type="month"]):not(:has(table)):not(:has(.emp-picker)) > label{
    margin:0;
    display:inline-block;
}

form:has(> input[type="date"]):not(:has(table)):not(:has(.emp-picker)) > input,
form:has(> input[type="month"]):not(:has(table)):not(:has(.emp-picker)) > input,
form:has(> input[type="date"]):not(:has(table)):not(:has(.emp-picker)) > button,
form:has(> input[type="month"]):not(:has(table)):not(:has(.emp-picker)) > button{
    margin:0;
}

@media(max-width:768px){
    input[type="date"],
    input[type="month"],
    input[type="time"]{
        max-width:100%;
        width:100%;
    }
}


/* =========================================================
   STATUS BADGES - one set used on every page
========================================================= */

.badge{
    display:inline-block;
    padding:4px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:600;
    line-height:1.4;
    white-space:nowrap;
    -webkit-print-color-adjust:exact;
    print-color-adjust:exact;
}

.badge-present{ background:#dcfce7; color:#166534; }
.badge-ontime { background:#ecfdf5; color:#047857; }
.badge-absent { background:#fee2e2; color:#991b1b; }
.badge-half   { background:#fef3c7; color:#92400e; }
.badge-leave  { background:#dbeafe; color:#1e40af; }
.badge-late,
.badge-sandwich{ background:#ffedd5; color:#9a3412; }
.badge-off,
.badge-neutral{ background:#f3f4f6; color:#4b5563; }

/* =========================================================
   TABLES - same text size and header wrapping everywhere
========================================================= */

table,
.attendance-history-table,
.attendance-table{
    font-size:14px;
}

table th{
    white-space:nowrap;
}


/* =========================================================
   FINAL UI PASS
   ========================================================= */

/* Buttons */
.btn-sm{padding:6px 12px;font-size:13px;}
.btn-danger{background:#dc2626;color:#fff;border:0;border-radius:6px;cursor:pointer;}
.btn-danger:hover{background:#b91c1c;}

/* Sidebar groups + current page */
.sidebar{overflow-y:auto;padding-bottom:30px;}
.side-group{padding:14px 25px 4px;font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#9ca3af;}
.sidebar a{padding:11px 25px;}
.sidebar a.current{background:#eff6ff;color:#1d4ed8;font-weight:600;border-left:4px solid #2563eb;padding-left:21px;}
.sidebar a.current:hover{background:#2563eb;color:#fff;}
.sidebar a.side-logout{margin-top:12px;border-top:1px solid #e5e7eb;}

/* Toast messages (replaces in-page banners, no layout shift) */
.success-message.toast{position:fixed;top:72px;right:20px;z-index:4000;max-width:360px;margin:0;padding:12px 16px;
  box-shadow:0 8px 24px rgba(0,0,0,.18);cursor:pointer;transition:opacity .5s,transform .5s;}
.success-message.toast-hide{opacity:0;transform:translateY(-10px);pointer-events:none;}

/* Quick date chips */
.quick-dates{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px;flex-basis:100%;}
.chip{background:#f3f4f6;border:1px solid #d1d5db;color:#374151;border-radius:999px;padding:4px 12px;font-size:13px;cursor:pointer;}
.chip:hover{background:#2563eb;border-color:#2563eb;color:#fff;}

/* Sticky Save bar on Mark Attendance */
.sticky-save{position:sticky;bottom:0;z-index:50;background:rgba(255,255,255,.96);border-top:1px solid #e5e7eb;
  padding:12px 0;margin-top:16px;text-align:right;}

/* Empty states */
.empty-state{text-align:center;color:#6b7280;padding:28px 12px;}

/* Compact dashboard alert */
.alert-strip{display:flex;align-items:center;justify-content:space-between;gap:12px;background:#fff7ed;border:1px solid #fdba74;
  color:#9a3412;border-radius:8px;padding:10px 14px;margin-bottom:16px;font-size:14px;}
.alert-strip a{color:#9a3412;font-weight:700;text-decoration:underline;}

/* Phone: tables become stacked cards */
@media (max-width:640px){
  table.stack-phone{display:block;border:0;}
  table.stack-phone thead{display:none;}
  table.stack-phone tbody,table.stack-phone tr,table.stack-phone td{display:block;width:100%;}
  table.stack-phone tr{margin-bottom:12px;border:1px solid #e5e7eb;border-radius:8px;background:#fff;padding:6px 0;height:auto !important;}
  table.stack-phone td{display:flex;justify-content:space-between;gap:12px;text-align:right;border:0;padding:6px 12px;}
  table.stack-phone td::before{content:attr(data-label);font-weight:600;color:#6b7280;text-align:left;}
  .success-message.toast{left:12px;right:12px;max-width:none;}
}

.half-box strong{color:#b45309;}

/* Topbar title is a link (home) */
a.system-title{color:#fff;text-decoration:none;}
a.system-title:hover{text-decoration:underline;}
a.system-title:focus-visible,.menu-btn:focus-visible,.logout-btn:focus-visible,.back-link:focus-visible,.sidebar a:focus-visible{outline:3px solid #93c5fd;outline-offset:2px;}

/* Back link */
.back-nav{margin:0 0 14px;}
.back-link{display:inline-block;padding:6px 14px;border:1px solid #d1d5db;border-radius:999px;background:#fff;color:#1f2937;
  text-decoration:none;font-size:14px;font-weight:600;}
.back-link:hover{background:#2563eb;border-color:#2563eb;color:#fff;}
@media print{.back-nav{display:none;}}
