/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a9ca0;
  --primary-dark: #148285;
  --primary-light: #22b5ba;
  --primary-bg: #e8f6f6;
  --accent: #1a9ca0;
  --danger: #e74c3c;
  --bg: #f5f7f7;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dce3e3;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --radius: 8px;
}

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

.hidden { display: none !important; }

/* === LOGIN === */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
}

.login-box {
  background: white;
  padding: 48px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 90%;
  max-width: 400px;
}

.login-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
}

.login-box h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
  color: var(--primary);
}

.login-subtitle {
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.login-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-login {
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-login.admin { color: var(--primary); border-color: var(--primary); }
.btn-login.admin:hover { background: var(--primary); color: white; }
.btn-login.viewer { color: var(--primary-dark); border-color: var(--primary-dark); }
.btn-login.viewer:hover { background: var(--primary-dark); color: white; }

.admin-password {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-password input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  text-align: center;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
}

/* === HEADER === */
header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.menu-toggle {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text);
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.user-badge.admin { background: #dff0d8; color: #3c763d; }
.user-badge.viewer { background: #d9edf7; color: #31708f; }

.header-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}

.header-btn:hover { background: #f0f0f0; }

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  left: -280px;
  top: 0;
  width: 280px;
  height: 100vh;
  background: white;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  z-index: 200;
  transition: left 0.3s;
}

.sidebar.open { left: 0; }

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

.sidebar-header h2 { font-size: 1.1rem; }

.sidebar-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

.sidebar-menu {
  list-style: none;
  padding: 8px 0;
}

.sidebar-menu li a {
  display: block;
  padding: 14px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-menu li a:hover { background: #f5f5f5; }
.sidebar-menu li a.active {
  border-left-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
}

/* === MAIN === */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-secondary:hover { border-color: var(--primary-light); }

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-icon {
  background: white;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { border-color: var(--primary-light); }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* === WEEKS LIST === */
.week-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.week-item:hover { box-shadow: var(--shadow); border-color: var(--primary-light); }

.week-item.current {
  background: #d4edda;
  border-color: #b7dfbf;
}

.week-item .week-info h3 {
  font-size: 1rem;
  font-weight: 600;
}

.week-item .week-info p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 2px;
}

.week-item .week-label {
  font-size: 0.8rem;
  color: var(--text-light);
}

.week-item .week-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.week-item .week-actions button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px;
}

.week-item .week-actions button:hover { color: var(--text); }

/* === GANTT VIEW === */
.gantt-toolbar, .table-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.gantt-toolbar h2, .table-toolbar h2 {
  font-size: 1.15rem;
  min-width: 240px;
  text-align: center;
}

.gantt-day {
  margin-bottom: 24px;
}

.gantt-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.gantt-day-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.gantt-day-header .day-actions {
  display: flex;
  gap: 6px;
}

.gantt-day-header .day-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-light);
}

.gantt-day-header .day-actions button:hover { color: var(--text); border-color: var(--text); }

.gantt-chart {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px 8px;
  position: relative;
  min-height: 60px;
}

.gantt-timeline {
  position: relative;
  margin-bottom: 4px;
}

.gantt-bar-row {
  position: relative;
  height: 28px;
  margin-bottom: 4px;
}

.gantt-bar {
  position: absolute;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  border: 1px solid rgba(0,0,0,0.1);
  transition: opacity 0.15s;
}

.gantt-bar:hover { opacity: 0.85; }

.gantt-bar .bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-time-axis {
  display: flex;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.gantt-time-label {
  flex: 1;
  text-align: left;
  font-size: 0.7rem;
  color: var(--text-light);
}

.gantt-empty {
  color: var(--text-light);
  font-style: italic;
  font-size: 0.9rem;
  padding: 8px 0;
}

/* === TABLE VIEW === */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.schedule-table th {
  background: var(--primary);
  color: white;
  padding: 10px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.15);
}

.schedule-table th:first-child {
  text-align: left;
  padding-left: 12px;
}

.schedule-table th.today { background: var(--primary-light); }
.schedule-table th.weekend { background: var(--primary-dark); }

.schedule-table td {
  padding: 6px 4px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  vertical-align: middle;
  min-height: 40px;
}

.schedule-table td:first-child {
  text-align: left;
  padding-left: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #fafafa;
}

.schedule-table td.weekend { background: #f8f8f8; }
.schedule-table td.today { background: var(--primary-bg); }

.schedule-table .emp-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emp-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  background: #999;
}

.table-cell-shift {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
  color: white;
  cursor: pointer;
}

.table-cell-shift:hover { opacity: 0.8; }

.table-cell-empty {
  cursor: pointer;
  min-height: 32px;
  display: block;
}

.table-cell-empty:hover { background: var(--primary-bg); }

.schedule-table .hours-cell {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--primary);
  background: #f0f7ff;
}

/* === EMPLOYEES LIST === */
.employee-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
}

.employee-item:hover { opacity: 0.85; }

.employee-item .emp-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.8rem;
  margin-right: 16px;
}

.employee-item .emp-info {
  flex: 1;
}

.employee-item .emp-info h3 {
  font-size: 1rem;
  font-weight: 600;
}

.employee-item .emp-info p {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 2px;
}

.employee-item .emp-arrow {
  font-size: 1.2rem;
  color: rgba(0,0,0,0.3);
}

/* === SETTINGS === */
.settings-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.settings-section h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.settings-section .form-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.settings-section input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  flex: 1;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 1.05rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

.modal-body { padding: 20px; }

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

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Shift assignment modal */
.assign-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assign-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}

.assign-option:hover {
  border-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.assign-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.assign-option .opt-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.assign-option .opt-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.assign-option .opt-time {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-left: auto;
}

.assign-custom {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.assign-custom h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  header h1 { font-size: 0.95rem; }

  main { padding: 12px 8px; }

  .gantt-toolbar h2, .table-toolbar h2 {
    font-size: 0.95rem;
    min-width: auto;
  }

  .schedule-table { font-size: 0.75rem; }
  .schedule-table th, .schedule-table td { padding: 6px 3px; }

  .view-header { flex-wrap: wrap; gap: 8px; }
}

/* === PRINT === */
@media print {
  body { background: white; }

  .login-screen,
  header,
  .sidebar,
  .sidebar-overlay,
  .modal-overlay,
  .btn-icon,
  .day-actions,
  .admin-only-btn,
  .gantt-toolbar button,
  .table-toolbar button,
  #btn-print,
  #btn-logout,
  .week-actions { display: none !important; }

  main {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  #app { display: block !important; }

  .view.active { display: block !important; }

  .gantt-toolbar, .table-toolbar {
    justify-content: flex-start;
    margin-bottom: 8px;
  }

  .print-header {
    display: block !important;
    text-align: center;
    font-size: 14pt;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #333;
  }

  .print-header span {
    display: block;
    font-size: 10pt;
    font-weight: 400;
    color: #666;
  }

  .gantt-bar {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .schedule-table th {
    background: #333 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .table-cell-shift, .emp-avatar {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .week-item.current {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .gantt-day { page-break-inside: avoid; }

  .print-footer {
    display: block !important;
    text-align: right;
    font-size: 9pt;
    color: #666;
    margin-top: 16px;
    border-top: 1px solid #ccc;
    padding-top: 4px;
  }

  @page {
    margin: 1.5cm;
    size: landscape;
  }
}

.print-header, .print-footer { display: none; }
