/* ============================================
   CSS Custom Properties — Dual Theme System
   ============================================ */

/* ===== DARK THEME (default) ===== */
:root, [data-bs-theme="dark"] {
    /* Surfaces */
    --surface-primary: #0d1117;
    --surface-secondary: #161b22;
    --surface-tertiary: #1c2128;
    --surface-hover: #1c2333;
    --surface-active: #263040;

    /* Borders */
    --border-primary: #30363d;
    --border-secondary: #21262d;
    --border-accent: #58a6ff;

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --text-link: #58a6ff;
    --text-on-accent: #ffffff;

    /* Semantic */
    --color-accent: #58a6ff;
    --color-success: #3fb950;
    --color-warning: #d29922;
    --color-danger: #f85149;
    --color-info: #79c0ff;

    /* Schedule-specific */
    --gap-bg: rgba(248, 81, 73, 0.15);
    --gap-border: #f85149;
    --weekend-bg: #10151e;
    --holiday-bg: #1a0a0a;
    --today-bg: #0c1929;
    --locked-bg: rgba(88, 166, 255, 0.05);
    --violation-bg: rgba(210, 153, 34, 0.15);
}

/* ===== LIGHT THEME ===== */
[data-bs-theme="light"] {
    /* Surfaces */
    --surface-primary: #ffffff;
    --surface-secondary: #f6f8fa;
    --surface-tertiary: #eef1f5;
    --surface-hover: #e9ecef;
    --surface-active: #dde1e6;

    /* Borders */
    --border-primary: #d0d7de;
    --border-secondary: #dee2e6;
    --border-accent: #0969da;

    /* Text */
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-tertiary: #8c959f;
    --text-link: #0969da;
    --text-on-accent: #ffffff;

    /* Semantic */
    --color-accent: #0969da;
    --color-success: #1a7f37;
    --color-warning: #9a6700;
    --color-danger: #cf222e;
    --color-info: #218bff;

    /* Schedule-specific */
    --gap-bg: rgba(207, 34, 46, 0.08);
    --gap-border: #cf222e;
    --weekend-bg: #f0f4ff;
    --holiday-bg: #fff5f5;
    --today-bg: #ddf4ff;
    --locked-bg: rgba(9, 105, 218, 0.04);
    --violation-bg: rgba(154, 103, 0, 0.08);
}

/* ============================================
   Grafikas - Work Schedule Management Styles
   ============================================ */

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-primary);
}

/* Theme toggle button */
.theme-toggle-btn {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1100;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.theme-toggle-btn:hover {
    opacity: 1;
}

/* Navbar */
.navbar {
    padding: 0.5rem 1rem;
}

/* Responsive navbar */
@media (max-width: 767.98px) {
    .navbar {
        padding: 0.25rem 0.5rem;
    }
    .navbar .navbar-brand {
        font-size: 1rem;
    }
    #currentMonthLabel {
        font-size: 0.85rem !important;
        min-width: 100px !important;
    }
}

/* Tabs */
#mainTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#mainTabs::-webkit-scrollbar {
    display: none;
}
#mainTabs .nav-link {
    white-space: nowrap;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem 1rem;
}
#mainTabs .nav-link.active {
    color: var(--color-accent);
    background: transparent;
    border-bottom: 2px solid var(--color-accent);
}
#mainTabs .nav-link:hover {
    color: var(--text-primary);
}

/* Tab icon spacing */
#mainTabs .nav-link i {
    font-size: 1.1rem;
}
#mainTabs .nav-link .tab-label {
    margin-left: 0.4rem;
    font-size: 0.85rem;
}

/* Mobile: icon-only tabs */
@media (max-width: 767.98px) {
    #mainTabs .nav-link .tab-label {
        display: none;
    }
    #mainTabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 1.2rem;
    }
    #mainTabs .nav-link i {
        font-size: 1.2rem;
    }
}

/* Schedule Grid */
.schedule-week {
    margin-bottom: 1.5rem;
}
.schedule-week-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border-secondary);
}
.schedule-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.8rem;
}
.schedule-table th {
    background: var(--surface-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.4rem 0.25rem;
    text-align: center;
    border: 1px solid var(--border-secondary);
    font-size: 0.75rem;
}
.schedule-table th.day-header {
    min-width: 70px;
}
.schedule-table th.emp-header {
    width: 130px;
    min-width: 130px;
    text-align: left;
    padding-left: 0.5rem;
}
.schedule-table th.total-header {
    width: 55px;
    min-width: 55px;
}
.schedule-table td {
    border: 1px solid var(--border-secondary);
    padding: 0;
    vertical-align: middle;
    text-align: center;
    height: 38px;
}
.schedule-table td.emp-name {
    text-align: left;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.schedule-table td.total-cell {
    font-weight: 600;
    color: var(--color-accent);
    background: var(--surface-secondary);
    font-size: 0.75rem;
}

/* Schedule cell */
.schedule-cell {
    cursor: pointer;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    transition: background 0.15s;
    position: relative;
    min-height: 36px;
}
.schedule-cell:hover {
    background: var(--surface-hover);
}
.schedule-cell.has-entry {
    border-left: 3px solid var(--pos-color, #6c757d);
}
.schedule-cell .entry-time {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
}
.schedule-cell .entry-pos {
    font-size: 0.6rem;
    color: var(--text-secondary);
    line-height: 1;
}
.schedule-cell .entry-note {
    font-size: 0.55rem;
    color: var(--color-warning);
    line-height: 1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Special day markers */
.day-holiday {
    background: var(--holiday-bg) !important;
}
.day-weekend {
    background: var(--weekend-bg) !important;
}
.day-today {
    background: var(--today-bg) !important;
}
.schedule-table th.day-weekend {
    background: var(--weekend-bg);
    color: var(--color-danger);
}
.schedule-table th.day-holiday-header {
    background: var(--holiday-bg);
    color: var(--color-danger);
}
.schedule-table th.day-today-header {
    border-bottom: 2px solid var(--color-accent);
}
.cell-marker {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.cell-marker.ndrb {
    color: var(--color-danger);
}
.cell-marker.unavail {
    color: var(--text-secondary);
}
.cell-marker.vacation {
    color: var(--color-success);
}

/* Employee table */
.emp-positions-badges .badge {
    font-size: 0.7rem;
}

/* Unavailable day picker */
.unavail-day-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.75rem;
    border-radius: 4px;
}
.unavail-day-btn.active {
    background: var(--color-danger) !important;
    border-color: var(--color-danger) !important;
    color: var(--text-on-accent) !important;
}

/* Summary cards */
.summary-card {
    background: var(--surface-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.summary-card .emp-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}
.summary-card .hours-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.summary-card .progress {
    height: 8px;
    background: var(--border-secondary);
}

/* Salary table */
.salary-table th,
.salary-table td {
    font-size: 0.85rem;
    padding: 0.5rem;
}
.salary-table .totals-row {
    font-weight: 700;
    background: var(--surface-secondary);
    border-top: 2px solid var(--color-accent);
}

/* Settings */
.settings-section {
    background: var(--surface-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.settings-section h5 {
    color: var(--color-accent);
    margin-bottom: 1rem;
}

/* Schedule toolbar */
.schedule-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Schedule toolbar responsive */
.schedule-toolbar .btn span.d-none {
    /* Text hidden on mobile by Bootstrap d-none d-md-inline */
}
@media (max-width: 767.98px) {
    .schedule-toolbar {
        justify-content: center;
    }
    .schedule-toolbar .btn {
        padding: 0.375rem 0.5rem;
    }
}

/* Mobile bottom-sheet modals */
@media (max-width: 767.98px) {
    .modal.fade .modal-dialog {
        margin: 0;
        max-width: 100%;
        display: flex;
        align-items: flex-end;
        min-height: 100vh;
    }
    .modal-content {
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        max-height: 90vh;
        overflow-y: auto;
    }
    .modal-dialog-centered .modal-dialog {
        align-items: flex-end;
    }
}

/* Touch-friendly targets (44px minimum) */
@media (max-width: 767.98px) {
    .schedule-cell {
        min-height: 44px;
    }
    .unavail-day-btn {
        width: 44px;
        height: 44px;
        font-size: 0.85rem;
    }
    .btn-sm {
        min-height: 36px;
        padding: 0.375rem 0.5rem;
    }
    .mobile-entry-card, .mobile-gap-card {
        min-height: 48px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .schedule-table {
        font-size: 0.7rem;
    }
    .schedule-table th.emp-header {
        width: 80px;
        min-width: 80px;
    }
    .schedule-cell .entry-time {
        font-size: 0.6rem;
    }
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Smooth theme transition */
body {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Gap cells */
.gap-cell {
    background: var(--gap-bg) !important;
    border: 1px dashed var(--gap-border) !important;
}
.gap-cell .gap-label {
    color: var(--color-danger);
    font-size: 0.7rem;
    font-weight: 600;
}

/* Violation cells */
.violation-cell {
    background: var(--violation-bg) !important;
}

/* Locked month indicator */
.locked-indicator {
    background: var(--locked-bg);
    border-left: 3px solid var(--border-accent);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Capacity dashboard */
.capacity-card {
    background: var(--surface-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}
.capacity-card .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.capacity-card .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.capacity-card.has-gaps .stat-number {
    color: var(--color-danger);
}
.capacity-card.has-violations .stat-number {
    color: var(--color-warning);
}

/* Capacity dashboard mobile tweaks */
@media (max-width: 767.98px) {
    .capacity-card {
        padding: 0.5rem;
    }
    .capacity-card .stat-number {
        font-size: 1.25rem;
    }
    .capacity-card .stat-label {
        font-size: 0.6rem;
    }
}

/* Coverage progress bars */
.coverage-bar {
    height: 6px;
    background: var(--border-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}
.coverage-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}
.coverage-bar-fill.coverage-full { background: var(--color-success); }
.coverage-bar-fill.coverage-partial { background: var(--color-warning); }
.coverage-bar-fill.coverage-low { background: var(--color-danger); }

/* Generation summary banner */
.generation-banner {
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}
.generation-banner.banner-success {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid var(--color-success);
    color: var(--color-success);
}
.generation-banner.banner-warning {
    background: var(--violation-bg);
    border: 1px solid var(--color-warning);
    color: var(--color-warning);
}
.generation-banner.banner-danger {
    background: var(--gap-bg);
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--surface-secondary) 25%, var(--surface-tertiary) 50%, var(--surface-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.empty-state i {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    color: var(--text-tertiary);
}
.empty-state p {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    @page {
        size: landscape;
        margin: 1cm;
    }
    .navbar, #mainTabs, .schedule-toolbar, .btn, .modal,
    .theme-toggle-btn, .generation-banner, .locked-indicator,
    .capacity-card, .toast-container {
        display: none !important;
    }
    .schedule-table {
        font-size: 9px;
    }
    .schedule-table th, .schedule-table td {
        border-color: #333 !important;
    }
    body {
        background: white !important;
        color: black !important;
    }
    .schedule-table th {
        background: #eee !important;
        color: black !important;
    }
    .schedule-table td.emp-name {
        background: #f5f5f5 !important;
        color: black !important;
    }
    .schedule-cell .entry-time {
        color: black !important;
    }
    .schedule-cell .entry-pos {
        color: #555 !important;
    }
    .schedule-cell .entry-note {
        color: #666 !important;
    }
    /* Gap cells: striped pattern for non-color printers */
    .schedule-cell.gap-cell {
        background: repeating-linear-gradient(
            45deg, transparent, transparent 3px,
            #ccc 3px, #ccc 4px
        ) !important;
    }
    .day-holiday, .day-weekend, .day-today {
        background: white !important;
    }
}

/* Scrollable schedule wrapper */
.schedule-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Business hours settings table */
.bh-table input[type="time"] {
    max-width: 130px;
}

/* Position color swatch */
.pos-color-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
}

/* Loading spinner */
.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}
.loading-spinner .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Mobile day view */
.mobile-day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
}
.mobile-day-nav .day-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}
.mobile-day-nav .day-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mobile-position-group {
    margin-bottom: 1rem;
}
.mobile-position-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--surface-secondary);
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--border-secondary);
    border-bottom: none;
}
.mobile-position-header .pos-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mobile-position-header .pos-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    color: var(--text-on-accent);
}

.mobile-entry-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 1px solid var(--border-secondary);
    border-top: none;
    background: var(--surface-primary);
    min-height: 44px;
    cursor: pointer;
    transition: background 0.15s;
}
.mobile-entry-card:last-child {
    border-radius: 0 0 8px 8px;
}
.mobile-entry-card:hover, .mobile-entry-card:active {
    background: var(--surface-hover);
}
.mobile-entry-card .entry-emp-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.mobile-entry-card .entry-time-range {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.mobile-gap-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px dashed var(--gap-border);
    border-top: none;
    background: var(--gap-bg);
    min-height: 44px;
    color: var(--color-danger);
    font-size: 0.85rem;
    font-weight: 500;
}
.mobile-gap-card:last-child {
    border-radius: 0 0 8px 8px;
}
.mobile-gap-card i {
    font-size: 1rem;
}

/* Mobile add button in position header */
.mobile-position-header .btn-add-entry {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1rem;
}

/* Mobile card layouts */
.employee-card, .position-card {
    background: var(--surface-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.employee-card .emp-card-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.employee-card .emp-card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.employee-card .emp-card-positions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}
.employee-card .emp-card-actions, .position-card .pos-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.position-card .pos-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.position-card .pos-card-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}
.position-card .pos-card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Toast positioning: mobile bottom-center, desktop top-right */
.toast-container {
    position: fixed;
    z-index: 1090;
}
@media (max-width: 767.98px) {
    .toast-container {
        bottom: 16px;
        left: 16px;
        right: 16px;
    }
}
@media (min-width: 768px) {
    .toast-container {
        top: 72px;
        right: 16px;
        width: 360px;
    }
}

/* Holiday indicators in mobile day view */
.day-holiday-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-danger);
    font-weight: 500;
}
.day-short-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-warning);
    font-weight: 500;
}

