﻿/* =====================================================
   File: wwwroot/css/schedule.css
   Planner Grid (2 sticky columns: ΣΕΙΡΑ + ΟΝΟΜΑ)
   - No page-level horizontal scroll: scroll stays inside the grid
   - Extra hours shown inline (compact hides text, keeps dot)
   - Bulk modal overlay styles included
   - EmployeeSchedulePage (mobile cards) styles included at the end
   ===================================================== */

/* ---------- Prevent page-level horizontal scroll ---------- */
.planner-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.planner-grid-host {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

/* ---------- Page header / toolbar ---------- */
.sched-title {
    margin: 0 0 12px 0;
}

.sched-muted {
    opacity: 0.7;
    padding: 8px 0;
}

.sched-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.sched-input {
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    min-width: 90px;
}

.sched-btn {
    padding: 7px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

    .sched-btn.secondary {
        opacity: 0.85;
    }

.sched-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ---------- Scroll container + sticky widths ---------- */
.sched-grid-wrap {
    --sticky-col1: 74px; /* ΣΕΙΡΑ */
    --sticky-col2: 240px; /* ΟΝΟΜΑ */

    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: auto;
    overscroll-behavior: contain;
    max-height: calc(100vh - 220px);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    -webkit-overflow-scrolling: touch;
}

    .sched-grid-wrap.compact {
        --sticky-col1: 56px;
        --sticky-col2: 190px;
    }

@media (max-width: 640px) {
    .sched-grid-wrap {
        --sticky-col1: 56px;
        --sticky-col2: 170px;
    }
}

/* ---------- Table ---------- */
.sched-grid {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 960px;
}

    .sched-grid th,
    .sched-grid td {
        border-bottom: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
        padding: 0;
        vertical-align: top;
    }

    /* Sticky header */
    .sched-grid thead th {
        position: sticky;
        top: 0;
        z-index: 10;
        background: #f8fafc;
        padding: 8px;
    }

/* Sticky columns */
.sticky-col {
    position: sticky;
    background: #fff;
    background-clip: padding-box;
}

.sticky-col-1 {
    left: 0;
    z-index: 6;
    min-width: var(--sticky-col1);
    max-width: var(--sticky-col1);
    text-align: center;
    box-shadow: 2px 0 0 rgba(226, 232, 240, 1);
}

.sticky-col-2 {
    left: var(--sticky-col1);
    z-index: 5;
    min-width: var(--sticky-col2);
    max-width: 320px;
    box-shadow: 2px 0 0 rgba(226, 232, 240, 1);
}

/* Top-left header cells */
.sticky-corner {
    z-index: 12 !important;
}

.sticky-corner-2 {
    z-index: 11 !important;
}

.order-col {
    font-weight: 800;
}

.name-col {
    padding: 8px;
    font-weight: 700;
    white-space: nowrap;
}

/* Employee name + avatar (Grid) */
.emp-name {
    display: flex;
    align-items: stretch;
    gap: 8px;
    height: 100%;
}

img.emp-avatar {
    height: 50px !important;
    width: 50px !important;
    aspect-ratio: 1 / 1;
    max-height: none !important;
    max-width: none !important;
    border-radius: 999px !important;
    object-fit: cover !important;
    display: block !important;
    flex: 0 0 auto !important;
    border: 1px solid rgba(226, 232, 240, 1);
}

.emp-text {
    display: flex;
    align-items: center;
}

/* Days */
.day-col {
    min-width: 86px;
    text-align: center;
    position: relative;
}

.day-num {
    font-weight: 800;
}

.day-dow {
    font-size: 12px;
    opacity: 0.7;
}

/* Cells */
.cell {
    min-width: 86px;
    height: 44px;
}

.cell-btn {
    width: 100%;
    height: 44px;
    border: 0;
    cursor: pointer;
    background: transparent;
    padding: 6px;
    text-align: center;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
}

/* Main text (new + backward compatible) */
.cell-main,
.cell-line-main {
    font-size: 12px;
    line-height: 1.05;
    white-space: nowrap;
}

/* Extra inline text (new + backward compatible) */
.cell-extra-text,
.cell-line-extra {
    font-size: 10px;
    line-height: 1;
    opacity: 0.9;
    white-space: nowrap;
}

/* Hours text variant (if you use it somewhere) */
.cell-line-hours {
    font-size: 10px;
    line-height: 1;
    opacity: 0.9;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Red dot when extra exists */
.cell-extra-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #dc2626;
    display: inline-block;
    flex: 0 0 6px;
}

/* Small badge in cell */
.cell-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    line-height: 1;
    padding: 1px 5px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.85);
    color: #fff;
    white-space: nowrap;
}

/* Focus marker used for auto-scroll */
.focus-marker {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* Compact mode days */
.sched-grid-wrap.compact .day-col,
.sched-grid-wrap.compact .cell {
    min-width: 70px;
}

.sched-grid-wrap.compact .cell-btn {
    height: 38px;
}

.sched-grid-wrap.compact .day-dow {
    display: none;
}

/* Compact mode: hide +xh text, keep dot */
.sched-grid-wrap.compact .cell-extra-text,
.sched-grid-wrap.compact .cell-line-extra,
.sched-grid-wrap.compact .cell-line-hours {
    display: none;
}

.sched-grid-wrap.compact .cell-badge {
    font-size: 9px;
    top: 3px;
    right: 3px;
}

/* Dialog (cell editor) */
.sched-dialog {
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 0;
    width: min(560px, calc(100vw - 24px));
}

.sched-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.sched-dialog-title {
    font-weight: 800;
}

.sched-x {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
}

.sched-dialog-body {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
}

.sched-dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
}

/* Row highlight (desktop) */
@media (hover: hover) and (pointer: fine) {
    .sched-grid tbody tr:hover td.sticky-col {
        background-image: linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05));
    }

    .sched-grid tbody tr:hover .cell-btn {
        filter: saturate(1.05) brightness(0.99);
    }
}

.sched-grid tbody tr:focus-within td.sticky-col {
    background-image: linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06));
}

.sched-grid tbody tr:focus-within .cell-btn {
    filter: saturate(1.03) brightness(0.99);
}

/* Mobile tweaks */
@media (max-width: 640px) {
    .sched-grid {
        min-width: 820px;
    }

    .day-dow {
        display: none;
    }
}

/* =====================================================
   Bulk modal overlay (always on top)
   ===================================================== */
.bulk-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.bulk-modal {
    width: min(780px, calc(100vw - 24px));
    max-height: min(86vh, 860px);
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.bulk-modal-head {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.bulk-modal-title {
    font-weight: 900;
}

.bulk-modal-x {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
}

.bulk-modal-body {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
}

.bulk-modal-actions {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 2;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
}

/* Bulk helpers */
.bulk-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.bulk-field {
    display: grid;
    gap: 6px;
}

.bulk-range {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.bulk-cal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.bulk-picked {
    margin-left: auto;
    opacity: 0.85;
    font-weight: 800;
}

/* Legend */
.bulk-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    opacity: 0.85;
}

.legend-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    border: 2px solid transparent;
}

    .legend-box.exist {
        border-color: #2563eb;
        background: rgba(37, 99, 235, 0.12);
    }

    .legend-box.hol {
        border-color: #f97316;
        background: rgba(249, 115, 22, 0.12);
    }

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
    background: rgba(15, 23, 42, 0.45);
}

/* Bulk calendar */
.bulk-cal {
    margin-top: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
}

.bulk-cal-head {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 6px;
}

.bulk-cal-h {
    text-align: center;
    font-weight: 900;
    opacity: 0.75;
    font-size: 12px;
}

.bulk-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.bulk-cal-empty {
    height: 34px;
}

.bulk-cal-day {
    height: 34px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-weight: 900;
}

    .bulk-cal-day.has {
        position: relative;
    }

        .bulk-cal-day.has::after {
            content: "";
            position: absolute;
            left: 50%;
            bottom: 6px;
            width: 6px;
            height: 6px;
            transform: translateX(-50%);
            border-radius: 999px;
            background: rgba(15, 23, 42, 0.45);
        }

    /* already same assignment */
    .bulk-cal-day.exist {
        box-shadow: inset 0 0 0 3px rgba(37, 99, 235, 0.85);
        background: rgba(37, 99, 235, 0.08);
    }

    /* official holiday */
    .bulk-cal-day.hol {
        box-shadow: inset 0 0 0 3px rgba(249, 115, 22, 0.85);
        background: rgba(249, 115, 22, 0.10);
    }

    /* sunday marker */
    .bulk-cal-day.sun {
        box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.6);
    }

    /* today marker */
    .bulk-cal-day.today {
        box-shadow: inset 0 0 0 3px rgba(22, 163, 74, 0.8);
    }

    /* selected strongest */
    .bulk-cal-day.sel {
        background: #111827;
        color: #fff;
        border-color: #111827;
        box-shadow: none;
    }

.bulk-error {
    margin-top: 8px;
    color: #dc2626;
    font-weight: 900;
}

/* =====================================================
   Centered modal ABOVE EVERYTHING (optional overlay editor)
   ===================================================== */
.cell-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.cell-editor {
    width: min(560px, calc(100vw - 24px));
    max-height: 86vh;
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* =====================================================
   EmployeeSchedulePage.razor (mobile-first cards)
   Scoped under .emp-page to avoid conflicts with grid .emp-name
   ===================================================== */
.emp-page {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 14px 12px 22px;
}

    .emp-page .emp-topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        background: #fff;
        padding: 10px 0 12px;
        border-bottom: 1px solid #e2e8f0;
    }

    .emp-page .emp-profile {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
    }

    .emp-page .emp-avatar-lg {
        width: 42px;
        height: 42px;
        border-radius: 999px;
        object-fit: cover;
        border: 1px solid #e2e8f0;
    }

    .emp-page .emp-profile-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .emp-page .emp-name {
        font-weight: 800;
        font-size: 16px;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .emp-page .emp-sub {
        opacity: 0.75;
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .emp-page .emp-monthbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .emp-page .emp-month {
        font-weight: 800;
        font-size: 15px;
        text-transform: capitalize;
    }

    .emp-page .emp-btn {
        border: 1px solid #cbd5e1;
        background: #fff;
        border-radius: 14px;
        padding: 8px 12px;
        cursor: pointer;
        min-width: 44px;
        font-size: 18px;
        line-height: 1;
    }

        .emp-page .emp-btn:active {
            transform: translateY(1px);
        }

    .emp-page .emp-cards {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding-top: 12px;
    }

@media (min-width: 720px) {
    .emp-page .emp-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .emp-page .emp-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.emp-page .emp-card {
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
}

    .emp-page .emp-card::before {
        content: "";
        position: absolute;
        inset: 0 auto 0 0;
        width: 6px;
        background: var(--accent, #e2e8f0);
    }

    .emp-page .emp-card.today {
        outline: 2px solid rgba(59, 130, 246, 0.25);
        outline-offset: 2px;
    }

.emp-page .emp-card-head {
    padding: 12px 12px 10px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.emp-page .emp-date-num {
    font-weight: 900;
    font-size: 16px;
}

.emp-page .emp-date-dow {
    opacity: 0.75;
    font-size: 13px;
    text-transform: capitalize;
}

.emp-page .emp-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.emp-page .emp-badge {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

    .emp-page .emp-badge.soft {
        opacity: 0.8;
    }

.emp-page .emp-card-body {
    padding: 0 12px 12px 16px;
}

.emp-page .emp-shift {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.emp-page .emp-shift-title {
    font-weight: 900;
    font-size: 16px;
}

.emp-page .emp-extra {
    font-size: 13px;
    opacity: 0.8;
}

.emp-page .emp-muted {
    opacity: 0.75;
    padding: 10px 0;
}

.emp-page .emp-muted-sm {
    opacity: 0.7;
    font-size: 12px;
}

.emp-page .emp-error {
    border: 1px solid #fecaca;
    background: #fff1f2;
    color: #9f1239;
    padding: 12px;
    border-radius: 14px;
}

@media (prefers-reduced-motion: reduce) {
    .emp-page .emp-btn:active {
        transform: none;
    }
}

@media (max-width: 360px) {
    .emp-page {
        padding: 12px 10px 18px;
    }

        .emp-page .emp-btn {
            padding: 8px 10px;
        }

        .emp-page .emp-card-head {
            padding: 12px 10px 10px 14px;
        }

        .emp-page .emp-card-body {
            padding: 0 10px 12px 14px;
        }
}
