/* public/styles.css */
:root {
  --primary: #007749;  /* SA green */
  --primary-dark: #005c38;
  --secondary: #de3831;  /* SA red */
  --gold: #ffb81c;  /* SA gold */
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --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.6;
}

.hidden {
  display: none !important;
}

/* Auth Styles */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: var(--card);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 2rem;
}

.tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  padding: 0.9rem 1rem;
  border: 1px solid transparent;
  background: var(--card);
  cursor: pointer;
  border-radius: 12px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.tab:hover:not(.active) {
  background: #eef6f4;
  border-color: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.tab.active {
  background: var(--primary);
  color: white;
  border-color: rgba(255, 255, 255, 0.35);
  cursor: default;
}

.mini-tabs {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.calculator-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  max-width: 760px;
  margin: 0 auto;
}

.calculator-card h2 {
  margin-bottom: 0.75rem;
  color: var(--primary);
}

.calculator-card p {
  margin-bottom: 1rem;
  color: var(--text-light);
}

.calculator-form {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.overtime-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.overtime-total {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 0.9rem;
  background: #f0f5f0;
  border: 1px solid #dce9db;
  border-radius: 10px;
  color: #1f4d29;
  font-weight: 600;
}

.overtime-summary {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.overtime-summary label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 700;
}

.overtime-summary input {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-bottom: 3px double #1a1a2e;
  background: transparent;
  color: #1a1a2e;
}

.overtime-summary input:read-only {
  background: transparent;
  cursor: default;
}

.calculator-form label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.calculator-result {
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 120px;
}

.calculator-result p {
  margin: 0.65rem 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input {
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn.secondary {
  background: var(--bg);
  color: var(--text);
}

.error {
  color: var(--secondary);
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
}

/* Chat Styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

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

.header h1 {
  font-size: 1.25rem;
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#user-email {
  color: var(--text-light);
  font-size: 0.875rem;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 1rem;
  overflow: hidden;
}

#chat-panel,
#paye-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

#paye-panel {
  padding-top: 0.5rem;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  display: flex;
  gap: 1rem;
  max-width: 85%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-content {
  background: var(--card);
  padding: 1rem 1.25rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.message.user .message-content {
  background: var(--primary);
  color: white;
}

.message-content ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.message-content li {
  margin: 0.25rem 0;
}

.sources-link {
  display: inline-block;
  margin-top: 0.75rem;
  color: var(--primary);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: underline;
}

.message.user .sources-link {
  color: var(--gold);
}

.input-area {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

#question-input {
  flex: 1;
  border: none;
  resize: none;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
}

#question-input:focus {
  outline: none;
}

.send-btn {
  align-self: flex-end;
}

/* Sources Panel */
.sources-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 350px;
  background: var(--card);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 100;
}

.sources-panel h3 {
  margin-bottom: 1rem;
  color: var(--primary);
}

.source-item {
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.source-item strong {
  display: block;
  margin-bottom: 0.25rem;
}

.source-item small {
  color: var(--text-light);
}

#close-sources {
  margin-top: 1rem;
  width: 100%;
}

/* Loading State */
.loading {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
}

.loading span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

#admin-link{
    margin-left: 1rem;
    color: var(--primary);
    font-weight: 600;
}
.hidden{display:none;}

.loading span:nth-child(1) { animation-delay: -0.32s; }
.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
  .sources-panel {
    width: 100%;
  }
  
  .message {
    max-width: 95%;
  }
}
