/* SDS - Staff Deployment System */
:root {
    --primary: #2c3e50;
    --primary-light: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --secondary: #95a5a6;
    --bg: #f5f6fa;
    --card-bg: #fff;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #dfe6e9;
    --radius: 8px;
}

* { 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;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: calc(100vh - 60px);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary-light); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-large { padding: 0.8rem 2rem; font-size: 1.2rem; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 500;
}
.alert-success { background: #d5f4e6; color: #1e7e34; }
.alert-error { background: #fce4ec; color: #c62828; }
.alert-warning { background: #fff3cd; color: #856404; }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h3 { margin-bottom: 0.75rem; }
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th, .data-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}
.data-table tr:hover { background: #f8f9fa; }
.highlight-row { background: #eaf4ff !important; font-weight: 500; }
.break-row { background: #fef9e7; }

/* Forms */
.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; font-size: 0.9rem; }
.inline-form { display: inline-flex; gap: 0.25rem; }

input[type="text"], input[type="number"], input[type="password"],
input[type="date"], input[type="time"], input[type="email"],
select, textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
}
select { min-width: 150px; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.25rem;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}
.status-scheduled { background: #e3f2fd; color: #1565c0; }
.status-clocked_in { background: #e8f5e9; color: #2e7d32; }
.status-on_break { background: #fff3e0; color: #e65100; }
.status-clocked_out { background: #f5f5f5; color: #616161; }
.status-no_show { background: #fce4ec; color: #c62828; }
.status-early_release { background: #fff9c4; color: #f57f17; }
.status-extended { background: #e8eaf6; color: #283593; }
.status-pending { background: #fff3cd; color: #856404; }
.status-approved { background: #d5f4e6; color: #1e7e34; }
.status-denied { background: #fce4ec; color: #c62828; }
.status-inactive { background: #f5f5f5; color: #9e9e9e; }

.code-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: #ecf0f1;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    font-weight: 600;
}

.role-badge { padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.8rem; }
.role-employee { background: #e3f2fd; color: #1565c0; }
.role-supervisor { background: #f3e5f5; color: #6a1b9a; }
.role-manager { background: #fce4ec; color: #c62828; }

.type-badge { padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; }
.type-early_release { background: #fff3cd; color: #856404; }
.type-extend_shift { background: #e8eaf6; color: #283593; }

.cert-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    background: #e8f5e9;
    border-radius: 12px;
    font-size: 0.75rem;
    margin: 0.1rem;
}
.cert-remove {
    background: none;
    border: none;
    color: #c62828;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    line-height: 1;
}

.text-muted { color: var(--text-muted); }
.text-break { font-style: italic; color: var(--warning); }

/* Terminal page */
.terminal-page { background: var(--primary); }
.terminal-page .container { display: flex; flex-direction: column; align-items: center; justify-content: center; }

.terminal {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.terminal-title {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}
.terminal-form label {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}
.terminal-form .input-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
}
.terminal-form .input-large:focus {
    border-color: var(--primary-light);
}
.terminal-info h2 { margin-bottom: 0.5rem; }
.shift-info { color: var(--text-muted); margin-bottom: 1rem; font-size: 1.05rem; }

.terminal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Assignment result */
.assignment-card {
    background: #f8f9fa;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1rem 0;
}
.assignment-card h3 { color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; }

.position-badge {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}
.badge-position { background: var(--primary-light); color: #fff; }
.badge-break { background: var(--warning); color: #fff; }
.badge-task { background: #8e44ad; color: #fff; }
.duration { color: var(--text-muted); font-size: 0.9rem; }

.chain-table { text-align: left; }
.deployment-chain { margin-top: 1.5rem; text-align: left; }
.deployment-chain h3 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.5rem; }

.print-actions { margin-top: 1rem; }
.current-assignment { margin: 1rem 0; }
.task-description { color: var(--text-muted); font-size: 0.9rem; margin: 0.5rem 0; }

/* ER/ES forms */
.er-es-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.er-es-forms .card h3 { margin-bottom: 0.25rem; }
.er-es-forms .card p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.er-es-forms label { display: block; font-size: 0.85rem; font-weight: 500; margin: 0.5rem 0 0.25rem; }
.er-es-forms input, .er-es-forms textarea { width: 100%; }
.er-es-forms button { margin-top: 0.75rem; width: 100%; }

/* Admin */
.admin-header { margin-bottom: 1.5rem; }
.admin-header h1 { margin-bottom: 0.75rem; }
.admin-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.admin-nav a {
    padding: 0.4rem 0.8rem;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}
.admin-nav a:hover { background: var(--bg); }
.admin-nav a.active { background: var(--primary-light); color: #fff; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.dashboard-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.dashboard-card h3 { font-size: 2.5rem; color: var(--primary-light); }
.dashboard-card p { color: var(--text-muted); margin: 0.25rem 0 0.75rem; }
.dashboard-card a { color: var(--primary-light); text-decoration: none; font-size: 0.85rem; }
.dashboard-card.highlight { border: 2px solid var(--warning); }
.dashboard-card.highlight h3 { color: var(--warning); }

/* Live view */
.live-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.rotation-visual {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.rotation-slot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.slot-position { border-left: 4px solid var(--primary-light); }
.slot-break { border-left: 4px solid var(--warning); background: #fef9e7; }
.slot-empty { opacity: 0.5; }
.slot-position-name { font-weight: 600; min-width: 120px; }
.slot-employee { flex: 1; }
.slot-time { font-size: 0.8rem; color: var(--text-muted); }

.stats-row {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}
.stat { text-align: center; }
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: var(--primary-light); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

.coverage-chart { margin-top: 0.5rem; }
.coverage-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.coverage-hour { font-size: 0.8rem; font-family: monospace; min-width: 40px; }
.coverage-track {
    flex: 1;
    height: 16px;
    background: #ecf0f1;
    border-radius: 8px;
    overflow: hidden;
}
.coverage-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.3s;
}
.coverage-count { font-size: 0.8rem; min-width: 30px; text-align: right; }

/* Timeline Gantt chart */
.timeline-card { overflow: hidden; }
.timeline-container { overflow-x: auto; padding-bottom: 0.5rem; }

.timeline-grid {
    display: grid;
    grid-template-columns: 130px 1fr;
    min-width: 900px;
    gap: 0;
}

.tl-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    border-right: 2px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
    min-height: 38px;
}
.tl-label-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-label-code {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
    font-weight: 400;
}
.tl-label-break { background: #fef9e7; }
.tl-header-label {
    background: transparent;
    border-bottom: 2px solid var(--border);
}

.tl-track {
    position: relative;
    min-height: 38px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}
.tl-track-break { background: #fffdf0; }
.tl-header-track {
    position: relative;
    min-height: 24px;
    background: transparent;
    border-bottom: 2px solid var(--border);
    overflow: visible;
}

.tl-hour-label {
    position: absolute;
    top: 2px;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
    white-space: nowrap;
}

.tl-gridline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #ecf0f1;
    z-index: 0;
}

.tl-block {
    position: absolute;
    top: 3px;
    bottom: 3px;
    border-radius: 4px;
    z-index: 1;
    display: flex;
    align-items: center;
    padding: 0 6px;
    overflow: hidden;
    cursor: default;
    transition: opacity 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.tl-block:hover { opacity: 1 !important; z-index: 5; }
.tl-block-current {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(52,152,219,0.5);
    z-index: 3;
}
.tl-block-break {
    background-image: repeating-linear-gradient(
        45deg, transparent, transparent 3px,
        rgba(255,255,255,0.2) 3px, rgba(255,255,255,0.2) 6px
    );
}
.tl-block-text {
    font-size: 0.7rem;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.tl-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--danger);
    z-index: 10;
    pointer-events: none;
}
.tl-now::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -4px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
}

/* Timeline legend */
.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}
.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Debug panel */
.debug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0.75rem;
}
.debug-action h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.debug-action p { font-size: 0.8rem; margin-bottom: 0; }

/* Footer */
.site-footer {
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
}
.footer-acc {
    background: var(--danger) !important;
    color: #fff !important;
    border-top-color: var(--danger) !important;
}
.footer-acc .changelog-trigger { color: #fff !important; }
.footer-acc span { color: #fff !important; }

.footer-content { display: flex; align-items: center; justify-content: center; gap: 0; }
.changelog-trigger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
}
.changelog-trigger:hover { color: var(--primary-light); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-body h2 { margin: 0.5rem 0; font-size: 1.3rem; }
.modal-body h3 { margin: 1rem 0 0.5rem; color: var(--primary-light); }
.modal-body ul { margin: 0.25rem 0 0.75rem 1.25rem; }
.modal-body li { margin-bottom: 0.25rem; }

/* Responsive */
@media (max-width: 768px) {
    .live-grid { grid-template-columns: 1fr; }
    .er-es-forms { grid-template-columns: 1fr; }
    .admin-nav { gap: 0.1rem; }
    .admin-nav a { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 0.35rem 0.5rem; }
}
