/* QB Multi-API Utility - Shared Styles
   Version: 2025-11-29
   Based on: Simple_QBT.html + BB Theme
*/

/* ============================================================================
   CSS VARIABLES - BB Theme + Status Colors
   ============================================================================ */
:root {
    /* BB Brand */
    --bb-red: #C8102E;
    --bb-red-hover: #A00D25;
    --bb-dark: #1A1A1A;

    /* Status */
    --status-success: #48bb78;
    --status-warning: #f59e0b;
    --status-error: #f56565;
    --status-error-bg: #fef2f2;
    --status-info: #4299e1;

    /* Neutral */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #6B7280; /* WCAG AA - 4.5:1 on white (was #a0aec0) */
    --border-color: #e2e8f0;
    --border-dark: #cbd5e0;

    /* Accent (from Simple_QBT) */
    --accent-purple: #667eea;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Lunch highlight */
    --lunch-bg: #fed7aa;
    --lunch-bg-hover: #fdba74;
    --lunch-border: #f97316;

    /* Multi-employee dark section */
    --employee-section-hover-bg: #2a2a2a;
    --employee-section-name-color: #fff;
    --employee-section-stats-color: #ccc;

    /* Progress log */
    --progress-log-text: #E5E7EB;
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    min-height: 100dvh;
}

h1, h2, h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
}

/* WCAG 2.2 AA - Keyboard focus indicator for all interactive elements */
button:focus-visible,
.btn:focus-visible,
.nav-tab:focus-visible,
.icon-btn:focus-visible,
.preset-btn:focus-visible,
.employee-tab:focus-visible,
.tab:focus-visible,
.modal-close:focus-visible,
.validation-item .action-btn:focus-visible,
.toast .close-toast:focus-visible,
.toast .toast-close:focus-visible {
    outline: 2px solid var(--bb-red);
    outline-offset: 2px;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ============================================================================
   HEADER / NAV BAR
   ============================================================================ */
.app-header {
    background: var(--bg-primary);
    padding: 12px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .logo h1 {
    font-size: 20px;
    color: var(--bb-dark);
}

.app-header .logo span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Status Lights */
.status-group {
    display: flex;
    gap: 16px;
    align-items: center;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-light.connected {
    background: var(--status-success);
    box-shadow: 0 0 6px var(--status-success);
}

.status-light.disconnected {
    background: var(--status-error);
}

.status-light.warning {
    background: var(--status-warning);
}

/* Nav Tabs */
.nav-tabs {
    display: flex;
    gap: 4px;
}

.nav-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.nav-tab.active {
    background: var(--bb-red);
    color: white;
}

.nav-tab .badge {
    background: var(--status-warning);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================ */
.main-content {
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
}

/* ============================================================================
   DATE RANGE SELECTOR
   ============================================================================ */
.date-range-bar {
    background: var(--bg-primary);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.date-range-bar label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.date-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
}

.date-input:focus {
    outline: 2px solid var(--bb-red);
    outline-offset: 2px;
    border-color: var(--bb-red);
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.1);
}

.date-presets {
    display: flex;
    gap: 6px;
}

.preset-btn {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: var(--bg-tertiary);
}

.preset-btn.active {
    background: var(--bb-red);
    color: white;
    border-color: var(--bb-red);
}

/* ============================================================================
   EMPLOYEE TABS
   ============================================================================ */
.employee-tabs {
    display: flex;
    gap: 4px;
    padding: 0 0 16px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.employee-tab {
    flex: 0 0 auto;
    min-width: 120px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.employee-tab:hover {
    background: var(--bg-tertiary);
}

.employee-tab.active {
    background: var(--bg-primary);
    border-bottom-color: transparent;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    position: relative;
    z-index: 1;
}

.employee-tab .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.employee-tab .hours {
    font-size: 12px;
    color: var(--text-secondary);
}

.employee-tab .hours.warning {
    color: var(--status-warning);
    font-weight: 600;
}

.employee-tab .hours.error {
    color: var(--status-error);
    font-weight: 600;
}

/* ============================================================================
   TIMESHEET TABLE
   ============================================================================ */
.timesheet-container {
    background: var(--bg-primary);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
}

.timesheet-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timesheet-header h2 {
    font-size: 18px;
}

.timesheet-summary {
    display: flex;
    gap: 24px;
}

.summary-item {
    text-align: center;
}

.summary-item .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-item .label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.timesheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.timesheet-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-dark);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.timesheet-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.timesheet-table tr:hover {
    background: var(--bg-secondary);
}

/* Week separator */
.timesheet-table tr.week-separator td {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    padding: 6px 12px;
}

/* Lunch row */
.timesheet-table tr.lunch-row {
    background: var(--lunch-bg);
}

.timesheet-table tr.lunch-row:hover {
    background: var(--lunch-bg-hover);
}

/* Overtime highlight */
.timesheet-table tr.overtime td {
    color: var(--status-warning);
}

/* Error highlight */
.timesheet-table tr.error td {
    color: var(--status-error);
}

/* ============================================================================
   VALIDATION PANEL
   ============================================================================ */
.validation-panel {
    background: var(--bg-primary);
    border-radius: 0;
    margin-top: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.validation-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.validation-header h3 {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.validation-header .count {
    background: var(--status-warning);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.validation-list {
    padding: 12px 20px;
}

.validation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid var(--status-warning);
}

.validation-item.error {
    border-left-color: var(--status-error);
    background: var(--status-error-bg);
}

.validation-item .icon {
    font-size: 16px;
}

.validation-item .message {
    flex: 1;
    font-size: 13px;
}

.validation-item .action-btn {
    padding: 4px 12px;
    font-size: 11px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.validation-item .action-btn:hover {
    background: var(--bg-tertiary);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--bb-red);
    color: white;
}

.btn-primary:hover {
    background: var(--bb-red-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-success {
    background: var(--status-success);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   MODAL SYSTEM
   ============================================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================================================
   TABS (for Settings)
   ============================================================================ */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab:hover {
    color: var(--bb-red);
}

.tab.active {
    color: var(--bb-red);
    border-bottom-color: var(--bb-red);
}

.tab-content {
    display: none;
}

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

/* ============================================================================
   SETTINGS FORM
   ============================================================================ */
.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.setting-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 16px;
    margin-bottom: 16px;
    align-items: center;
}

.setting-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-input {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
}

.setting-input:focus {
    outline: 2px solid var(--bb-red);
    outline-offset: 2px;
    border-color: var(--bb-red);
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.1);
}

.setting-input.monospace {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.setting-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Connection status box */
.connection-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-bottom: 20px;
}

.connection-box .status {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-log {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bb-dark);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--progress-log-text); /* Improved contrast for dark bg */
}

.progress-log .success { color: var(--status-success); }
.progress-log .error { color: var(--status-error); }
.progress-log .info { color: var(--status-info); }

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Success glow animation for buttons - v2026-02-03 | BB */
@keyframes successGlow {
    0% { box-shadow: 0 0 5px rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 20px rgba(34, 197, 94, 0.8), 0 0 30px rgba(34, 197, 94, 0.4); }
    100% { box-shadow: 0 0 5px rgba(34, 197, 94, 0.5); }
}

.btn-success-glow {
    animation: successGlow 0.8s ease-in-out 3;
    background-color: var(--status-success, #22C55E) !important;
    border-color: var(--status-success, #22C55E) !important;
    color: white !important;
}

.toast.info {
    background: var(--status-info, #4299e1);
    color: white;
}

.toast.success {
    background: var(--status-success);
    color: white;
}

.toast.warning {
    background: var(--status-warning);
    color: white;
}

.toast.error {
    background: var(--status-error);
    color: white;
}

.toast .close-toast,
.toast .toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    padding: 0 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.toast .toast-close:hover {
    opacity: 1;
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

/* ============================================================================
   SCROLLBAR
   ============================================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--status-success); }
.text-warning { color: var(--status-warning); }
.text-error { color: var(--status-error); }
.font-mono { font-family: 'Courier New', monospace; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none; }

/* ============================================================================
   WEEK COLLAPSE STYLES
   ============================================================================ */
.week-hidden {
    display: none !important;
}

.week-header-row[data-first-header] {
    cursor: pointer;
}

.week-header-row[data-first-header]:hover th:first-child {
    background: var(--status-warning);
}

.week-toggle {
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.2s;
}

.week-header-row.collapsed .week-toggle {
    transform: rotate(-90deg);
}

/* ============================================================================
   MULTI-EMPLOYEE SECTION STYLES
   ============================================================================ */
.employee-section-header {
    cursor: default;
}

.employee-section-header:hover td {
    background: var(--employee-section-hover-bg);
}

.employee-section {
    margin-bottom: 0;
}

.employee-section-name {
    color: var(--employee-section-name-color);
}

.employee-mini-stats {
    color: var(--employee-section-stats-color);
}

.employee-mini-stats strong {
    color: var(--employee-section-name-color);
}
