/* PR Timeclock — Clean modern UI */

:root {
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2d3436;
    --text-muted: #8395a7;
    --border: #dfe6e9;
    --primary: #0984e3;
    --primary-hover: #0770c2;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --info: #74b9ff;
    --edit-bg: #ffeaa7;
    --conflict-bg: #fab1a0;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    border-bottom: 2px solid var(--primary);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    padding: 0.75rem 0;
    white-space: nowrap;
}

.nav-tabs { display: flex; gap: 0; flex: 1; }

.nav-tab {
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.nav-tab:hover { color: var(--text); background: var(--bg); }
.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* User info in navbar */
.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    white-space: nowrap;
}
.user-info {
    color: var(--text);
    font-weight: 500;
}
.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}
.nav-link:hover {
    color: var(--primary);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* Page Header */
.page-header {
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}
.page-header-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.card-warning {
    border-left: 4px solid var(--warning);
    background: #fef9e7;
}
.card-danger {
    border-left: 4px solid var(--danger);
    background: #fdf2f2;
}

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.flash-success { background: #d5f5e3; color: #1e8449; }
.flash-error { background: #fdf2f2; color: var(--danger); }
.flash-info { background: #ebf5fb; color: #2471a3; }
.flash-warning { background: #fef9e7; color: #b7950b; }

/* Forms */
.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 140px;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(9, 132, 227, 0.15);
}
.form-group-btn { justify-content: flex-end; }

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #c8d6e5; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #00a085; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.85rem; }
.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-icon:hover { background: var(--bg); }
.btn-danger-icon:hover { background: #fdf2f2; color: var(--danger); }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8f9fa; }
.col-total { font-weight: 600; }

/* Employee reconciliation flag badges */
.emp-flag {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15em 0.55em;
    border-radius: 3px;
    white-space: nowrap;
}
.emp-flag-ok       { background: #d4edda; color: #1a5c2a; }
.emp-flag-warn     { background: #fff3cd; color: #856404; }
.emp-flag-inactive { background: #fde8d0; color: #7a3800; }
.emp-flag-missing  { background: #f8d7da; color: #721c24; }

/* Punch table specifics */
.punch-table td { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
.punch-table th { padding: 0.4rem 0.5rem; }

/* Editable cells */
.editable { cursor: pointer; position: relative; }
.editable:hover {
    background: #edf2f7;
    border-radius: 2px;
}
.inline-input {
    width: 100%;
    padding: 0.2rem 0.4rem;
    border: 2px solid var(--primary);
    border-radius: 3px;
    font-size: 0.82rem;
    background: white;
}

/* Row states */
.row-edited { background: #fef9e7 !important; }
.row-conflict { background: #fdf2f2 !important; }
.row-deleted td { text-decoration: line-through; color: var(--text-muted); opacity: 0.6; }
.row-deleted .badge { text-decoration: none; }
.row-deleted .action-cell { text-decoration: none; opacity: 1; }
.row-original td { background: #f8f9fa; border-bottom: 1px dashed var(--border); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-fetched { background: #ebf5fb; color: #2471a3; }
.badge-reviewed { background: #d5f5e3; color: #1e8449; }
.badge-exported { background: #d5f5e3; color: #1e8449; }
.badge-warning { background: #fef9e7; color: #b7950b; }
.badge-danger { background: #fdf2f2; color: var(--danger); }
.badge-edit { background: #fef9e7; color: #b7950b; }
.badge-new { background: #ebf5fb; color: #2471a3; }
.badge-info { background: #ebf5fb; color: #2471a3; }

/* Employee card */
.employee-card { padding: 0; overflow: visible; }
.employee-card.expanded { outline: 2px solid var(--primary); outline-offset: -1px; border-radius: var(--radius); }
.employee-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    user-select: none;
    z-index: 10;
    background: var(--card-bg);
    border-radius: 0 0 var(--radius) var(--radius);
    border-top: 1px solid var(--border);
}
.employee-header:hover { background: var(--bg); }
.employee-header h3 { font-size: 0.95rem; }
.employee-name { flex-shrink: 0; }
.employee-card.expanded .employee-name { font-weight: 700; }
.employee-summary {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.summary-item { white-space: nowrap; }
.toggle-icon {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.employee-punches { padding: 0 0.5rem 0.5rem; }

/* Action bar */
.action-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Warning list */
.warning-list {
    list-style: none;
    font-size: 0.85rem;
}
.warning-list li {
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    min-width: 600px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.text-muted { color: var(--text-muted); }
code { background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.85em; }

/* Source badges */
.source-badge { font-size: 0.8em; cursor: help; }
.source-cell { width: 2em; text-align: center; }

/* Row states */
.row-deleted { opacity: 0.5; text-decoration: line-through; }
.row-edited { background: #fffce0; }
.row-added { background: #e8f5e9; }
.row-undone { opacity: 0.5; background: #f5f5f5; }

/* Missed punch / warning row */
.row-warning { background: #fff3e0; }
.warning-icon { cursor: help; margin-left: 2px; }

/* Missing-punch placeholder rows */
.row-placeholder { background: #fffde7; border-style: dashed; border-color: #f9a825; }
.row-placeholder td { color: #9e9e9e; font-style: italic; }
.placeholder-dir { color: #f9a825 !important; font-weight: bold; }
.placeholder-msg { color: #e65100; font-size: 0.85em; }
.btn-add-missing { font-size: 1.1em; cursor: pointer; background: none; border: none; padding: 2px 6px; }
.badge-warning { background: #ff9800; color: #fff; padding: 0.1rem 0.45rem; border-radius: 10px; font-size: 0.8em; font-weight: 600; cursor: help; }
.badge-not-in-iif { background: #e0e0e0; color: #616161; padding: 0.1rem 0.45rem; border-radius: 10px; font-size: 0.7em; font-weight: 600; cursor: help; vertical-align: middle; }
.emp-display-id { background: #e8eaf6; color: #3949ab; padding: 0.1rem 0.5rem; border-radius: 10px; font-size: 0.72em; font-weight: 600; vertical-align: middle; font-family: monospace; }

/* Save flash animation */
.save-flash { animation: flashGreen 0.6s ease; }
@keyframes flashGreen {
    0% { background: #c8e6c9; }
    100% { background: transparent; }
}

/* Error flash animation for inline edits */
.error-flash { animation: flashRed 2s ease; }
@keyframes flashRed {
    0%   { background: #ffcdd2; }
    80%  { background: #ffcdd2; }
    100% { background: transparent; }
}
.inline-error-msg {
    position: absolute;
    z-index: 200;
    background: #c62828;
    color: #fff;
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    margin-top: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    pointer-events: none;
}

/* Toolbar card */
.toolbar-card { padding: 1rem; }
.toolbar-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.period-selector { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.toolbar-view { margin-left: 0.5rem; }
.toolbar-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.date-input { width: 100px; padding: 0.3rem 0.5rem; }
.sync-info { margin-top: 0.5rem; font-size: 0.85em; color: var(--text-muted); }
.text-warning { color: #e65100; }

/* Undo toolbar */
.undo-toolbar { display: flex; gap: 1rem; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }

/* Action badges */
.action-badge { padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.8em; font-weight: 600; }
.action-edit { background: #fff3e0; color: #e65100; }
.action-delete { background: #ffebee; color: #c62828; }
.action-add { background: #e8f5e9; color: #2e7d32; }
.action-restore { background: #e3f2fd; color: #1565c0; }

/* Status indicators */
.status-active { color: #2e7d32; font-weight: 600; }
.status-undone { color: var(--text-muted); font-style: italic; }

/* Inline input */
.inline-input { width: 100%; padding: 0.2rem 0.4rem; border: 2px solid var(--primary); border-radius: 3px; font: inherit; }

/* Searchable select dropdown */
.search-select-wrapper { position: relative; }
.search-select-input { width: 100%; }
.search-select-list {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
    max-height: 180px; overflow-y: auto;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
    display: none;
}
.search-select-option {
    padding: 0.3rem 0.5rem; cursor: pointer; font-size: 0.85em;
}
.search-select-option:hover { background: var(--info); color: #fff; }
.search-select-option.selected { background: #e3f2fd; font-weight: 600; }

/* Actions cell */
.actions-cell { white-space: nowrap; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1em; padding: 0.2rem; }
.btn-icon:hover { transform: scale(1.2); }

/* Button sizes */
.btn-sm { font-size: 0.8em; padding: 0.25rem 0.5rem; }

/* Empty state */
.empty-state { text-align: center; padding: 2rem; color: var(--text-muted); }

/* Punch table */
.punch-table { width: 100%; font-size: 0.85em; }
.punch-table th { background: var(--bg); padding: 0.4rem 0.5rem; text-align: left; font-weight: 600; }
.punch-table td { padding: 0.3rem 0.5rem; }
.punch-table td.editable:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: #f0f7ff; cursor: pointer; }
.punch-table td.editable { cursor: pointer; }
.punch-actions { padding: 0.5rem; }

/* Employee header focusable */
.employee-header:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Responsive */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; gap: 1rem; }
    .container { padding: 1rem; }
    .form-row { flex-direction: column; }
    .modal-content { min-width: auto; margin: 1rem; }
    .toolbar-form { flex-direction: column; }
    .toolbar-actions { margin-left: 0; }
}

/* Timeclock sync status page */
.row-today { background: #e3f2fd; font-weight: 600; }
.row-pending td { color: var(--text-muted); }

.sync-badge { padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.8em; font-weight: 600; }
.sync-ok { background: #e8f5e9; color: #2e7d32; }
.sync-partial { background: #fff3e0; color: #e65100; }
.sync-pending { background: #f5f5f5; color: #9e9e9e; }
.sync-nodata { background: #fafafa; color: #bdbdbd; }

/* Per-row undo button */
.btn-row-undo { font-size: 1.1em; opacity: 0.7; }
.btn-row-undo:hover { opacity: 1; }

/* Duration-only rows (non-worked): merged in/out cell */
.cell-na { text-align: center; color: var(--text-muted); font-style: italic; }

/* Direction labels */
.dir-cell { font-size: 0.75em; font-weight: 700; text-transform: uppercase; width: 2.5em; text-align: center; }
.dir-in { color: #2e7d32; }
.dir-out { color: #c62828; }

/* Shift bracket pairing */
.shift-paired.shift-top { border-left: 3px solid #90caf9; }
.shift-paired.shift-bottom { border-left: 3px solid #90caf9; }
.shift-paired.shift-top td { border-bottom: none; padding-bottom: 0.1rem; }
.shift-paired.shift-bottom td { border-top: none; padding-top: 0.1rem; }
.shift-paired.shift-top td:first-child { border-top-left-radius: 4px; }
.shift-paired.shift-bottom td:first-child { border-bottom-left-radius: 4px; }

/* Shift separator — visible gap between shifts */
.punch-table tbody tr.shift-top:not(:first-child) td,
.punch-table tbody tr.shift-single:not(:first-child) td { border-top: 1px solid var(--border); }

/* Direction labels */
.dir-cell { font-size: 0.75em; font-weight: 700; text-transform: uppercase; width: 2.5em; text-align: center; }
.dir-in { color: #2e7d32; }
.dir-out { color: #c62828; }

/* Lunch column */
.lunch-cell { font-size: 0.8em; color: #757575; text-align: center; white-space: nowrap; }
/* Read-only auto-calculated cell (Std, OT, Lch on OUT row) */
.calc-cell { color: var(--text-muted); font-style: italic; font-size: 0.88em; text-align: right; cursor: default; user-select: none; }
.punch-table td.calc-cell { cursor: default; }
.punch-table td.calc-cell:focus { outline: none; }

/* Shift bracket pairing */
.shift-paired.shift-top td { border-bottom: none; padding-bottom: 0.1rem; }
.shift-paired.shift-bottom td { border-top: none; padding-top: 0.1rem; }
.shift-paired.shift-top { border-left: 3px solid #90caf9; }
.shift-paired.shift-bottom { border-left: 3px solid #90caf9; }
.shift-paired.shift-top td:first-child { border-top-left-radius: 4px; }
.shift-paired.shift-bottom td:first-child { border-bottom-left-radius: 4px; }

/* Shift separator — gap between shifts */
.punch-table tbody tr.shift-top:not(:first-child) td,
.punch-table tbody tr.shift-single:not(:first-child) td { border-top: 1px solid var(--border); }

/* Daily total row in punch table */
.daily-total-row td { border-top: 2px solid var(--border) !important; background: var(--bg); font-size: 0.82em; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.daily-total-label { text-align: right; font-weight: 600; color: var(--text-muted); letter-spacing: 0.03em; padding-right: 0.5rem !important; }
.daily-total-hours { text-align: right; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.daily-total-total { text-align: right; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Side-by-side card layout */
.card-row { display: flex; gap: 1.5rem; margin-bottom: 1rem; }
.card-half { flex: 1; min-width: 0; }
