/* MyHR Styles — uses shared theme variables */

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

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

/* Loading */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border, #ddd);
  border-top-color: var(--color-primary, #0066cc);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Login */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
}

.login-card h1 {
  margin-bottom: 0.5rem;
}

.login-card p {
  margin-bottom: 1.5rem;
  color: var(--color-text-secondary, #666);
}

/* App container */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border, #ddd);
}

.app-header h1 {
  font-size: 1.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-name {
  font-size: 0.85rem;
  color: var(--color-text-secondary, #666);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a1a);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: var(--color-hover, #f0f0f0); }

.btn-primary {
  background: var(--color-primary, #0066cc);
  color: #fff;
  border-color: var(--color-primary, #0066cc);
}
.btn-primary:hover { opacity: 0.9; }

.btn-danger {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-hover, #f0f0f0); }

.btn-small { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-large { padding: 0.75rem 1.5rem; font-size: 1rem; }

.btn-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  padding: 0 0.25rem;
}

/* Messages */
.error-banner, .success-banner {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.error-banner {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.success-banner {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Idle Timer Banner */
.idle-banner {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.idle-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary, #666);
  margin-bottom: 0.35rem;
}

.idle-icon {
  font-size: 1rem;
}

.idle-bar-track {
  height: 4px;
  background: var(--color-border, #ddd);
  border-radius: 2px;
  overflow: hidden;
}

.idle-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 1s linear;
}

.idle-bar-ok { background: #22c55e; }
.idle-bar-warning { background: #f59e0b; }
.idle-bar-danger { background: #ef4444; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border, #ddd);
  margin-bottom: 1rem;
}

.tabs button {
  padding: 0.5rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text-secondary, #666);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tabs button:hover {
  color: var(--color-text, #1a1a1a);
}

.tabs button.active {
  color: var(--color-primary, #0066cc);
  border-bottom-color: var(--color-primary, #0066cc);
}

/* Section loading */
.section-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--color-text-secondary, #666);
}

/* Leave Balances */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.balance-card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 1rem;
  border-left: 4px solid;
}

.balance-ok { border-left-color: #22c55e; }
.balance-warning { border-left-color: #f59e0b; }
.balance-danger { border-left-color: #ef4444; }
.balance-exceeded { border-left-color: #dc2626; background: #fef2f2; }

/* Annual leave cap warning */
.leave-cap-warning {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  border-radius: 6px;
  color: #991b1b;
}

.leave-cap-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.leave-cap-content strong {
  display: block;
  margin-bottom: 0.25rem;
}

.leave-cap-content p {
  font-size: 0.875rem;
  margin: 0;
  line-height: 1.5;
}

.balance-name {
  font-size: 0.85rem;
  color: var(--color-text-secondary, #666);
  margin-bottom: 0.25rem;
}

.balance-hours {
  font-size: 1.25rem;
  font-weight: 600;
}

.balance-unit {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-text-secondary, #666);
  margin-left: 0.25rem;
}

.balance-days {
  font-size: 0.8rem;
  color: var(--color-text-secondary, #666);
  margin-top: 0.25rem;
}

/* Tables */
h2 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

h2:first-child {
  margin-top: 0;
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.table-wrap {
  overflow-x: auto;
}

.scrollable-table {
  max-height: 300px;
  overflow-y: scroll;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 6px;
  display: block;
}

.scrollable-table table {
  margin-bottom: 0;
}

.scrollable-table thead {
  position: sticky;
  top: 0;
  background: var(--color-surface, #fff);
  z-index: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

thead {
  background: var(--color-surface, #fff);
}

th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--color-border, #ddd);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-text-secondary, #666);
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border, #ddd);
}

.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
}

.clickable-row:hover {
  background: var(--color-hover, #f5f5f5);
}

.row-arrow {
  text-align: right;
  color: var(--color-text-secondary, #999);
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-approved { background: #dcfce7; color: #166534; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-rejected { background: #fef2f2; color: #991b1b; }

/* Payslip Detail */
.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-header h2 {
  margin-bottom: 0;
}

.payslip-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.detail-section {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 1rem;
}

.summary-section {
  max-width: 320px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.summary-total {
  border-top: 2px solid var(--color-border, #ddd);
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
}

/* Admin */
.admin-card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--color-text-secondary, #666);
}

.form-input {
  width: 100%;
  max-width: 300px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #1a1a1a);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary, #0066cc);
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #999);
  margin-top: 0.25rem;
}

.form-actions {
  margin-top: 1rem;
}

.settings-form {
  flex-direction: column;
  align-items: flex-start;
}

/* Team view */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.team-member-card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 1rem;
}

.member-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border, #ddd);
}

.member-balances {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.member-balance-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.member-balance-row small {
  color: var(--color-text-secondary, #666);
  margin-left: 0.25rem;
}

/* Member applications (inside team cards) */
.member-applications {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border, #ddd);
}

.member-app-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.25rem 0;
  flex-wrap: wrap;
}

.app-dates {
  color: var(--color-text-secondary, #666);
}

.approval-attribution {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #999);
  font-style: italic;
}

/* Approval buttons */
.approval-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-approve {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
}
.btn-approve:hover { opacity: 0.9; }

.btn-reject {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.btn-reject:hover { opacity: 0.9; }

/* Delegate form */
.delegate-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.delegate-form .form-input {
  max-width: 200px;
}

.link {
  color: var(--color-primary, #0066cc);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--color-text-secondary, #666);
  margin-bottom: 0.75rem;
}

/* Section headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.section-header h2 {
  margin-bottom: 0;
}

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

.modal {
  background: var(--color-surface, #fff);
  border-radius: 8px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border, #ddd);
}

.modal-header h3 {
  margin-bottom: 0;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border, #ddd);
}

.form-row-inline {
  display: flex;
  gap: 1rem;
}

.form-row-inline .form-group {
  flex: 1;
}

/* Admin status line */
.admin-status-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

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

/* Admin section box */
.admin-section-box {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.5rem;
}

/* Calendar */
.calendar-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.calendar-range {
  font-size: 0.9rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.calendar-options {
  display: flex;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
}

.calendar-view-switch {
  display: flex;
  gap: 0;
}

.calendar-view-switch .btn {
  border-radius: 0;
}
.calendar-view-switch .btn:first-child { border-radius: 6px 0 0 6px; }
.calendar-view-switch .btn:last-child { border-radius: 0 6px 6px 0; }

/* Timeline view */
.calendar-timeline-wrap {
  overflow-x: auto;
  overflow-y: visible;
  margin-bottom: 1rem;
}

.cal-timeline-row {
  display: grid;
  min-width: 900px;
}

.cal-timeline-header {
  border-bottom: 2px solid var(--color-border, #ddd);
}

.cal-name-col {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--color-border, #ddd);
}

.cal-staff-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-day-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.15rem;
  font-size: 0.7rem;
  border-right: 1px solid var(--color-border, #eee);
}

.cal-dow { color: var(--color-text-secondary, #999); font-size: 0.65rem; }
.cal-date { font-weight: 600; }

/* Instant tooltips */
[data-tip] {
  position: relative;
}

[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b4b;
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
  margin-top: 4px;
}

.cal-day-cell {
  min-height: 24px;
  border-right: 1px solid var(--color-border, #eee);
  border-bottom: 1px solid var(--color-border, #eee);
}

.cal-weekend { background: var(--color-hover, #f5f5f5); }
.cal-today { background: #e0f2fe !important; }
.cal-holiday-col { background: #e9d5ff !important; }
.cal-school-col { background: #fef3c7 !important; }
.cal-overlap-col { background: #fef3c7 !important; }

.cal-leave-approved { background: #22c55e !important; }
.cal-leave-pending { background: repeating-linear-gradient(45deg, #fbbf24, #fbbf24 4px, #fde68a 4px, #fde68a 8px) !important; }

.calendar-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #666);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--color-border, #ddd);
}

.cal-holiday-swatch { background: #e9d5ff; }
.cal-school-swatch { background: #fef3c7; }
.cal-company-swatch { background: #dbeafe; }

/* Holiday tooltip */
.cal-overlap-swatch { background: #fef3c7; }

/* Monthly grid view */
.calendar-grid-wrap {
  margin-bottom: 1rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--color-border, #ddd);
}

.cal-grid-header {
  padding: 0.35rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary, #666);
  background: var(--color-surface, #fff);
  border-bottom: 1px solid var(--color-border, #ddd);
}

.cal-grid-cell {
  min-height: 80px;
  padding: 0.25rem;
  border-right: 1px solid var(--color-border, #eee);
  border-bottom: 1px solid var(--color-border, #eee);
  font-size: 0.75rem;
  overflow: hidden;
}

.cal-grid-empty {
  background: var(--color-hover, #f9f9f9);
}

.cal-grid-date {
  font-weight: 600;
  font-size: 0.8rem;
}

.cal-grid-holidays {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
}

.cal-grid-holiday-pill {
  display: block;
  font-size: 0.6rem;
  padding: 1px 4px;
  border-radius: 3px;
  background: #e9d5ff;
  color: #6b21a8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  cursor: default;
}

.cal-grid-holiday-pill.holiday-public { background: #e9d5ff; color: #6b21a8; }
.cal-grid-holiday-pill.holiday-company { background: #dbeafe; color: #1e40af; }
.cal-grid-holiday-pill.holiday-school { background: #fef3c7; color: #92400e; }

.cal-grid-people {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.cal-grid-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 600;
  color: #fff;
}

.dot-approved { background: #22c55e; }
.dot-pending { background: #f59e0b; }

/* Overlap warning banner */
.overlap-banner {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  color: #92400e;
  font-size: 0.85rem;
}

.overlap-item {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 640px) {
  .balance-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .admin-card {
    flex-direction: column;
    gap: 1rem;
  }
}
