/* Mercury CFO Portal - Main Stylesheet */
/* Colors: White + UNT Green + Subtle Black + TCU Purple accents */

:root {
  --accent: #00853E;
  --accent-dark: #006630;
  --accent-purple: #4D1979;
  --accent-green: #00853E;
  --accent-orange: #e07b00;
  --accent-red: #c0392b;
  --text: #111111;
  --text-muted: #666666;
  --border: #e2e8e2;
  --border-dark: #cccccc;
  --card-bg: #ffffff;
  --page-bg: #f7f8f7;
  --hover: #f0f7f2;
  --shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Auth Screen ── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f7f2 0%, #ffffff 50%, #f5f0fa 100%);
}

.auth-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent-purple);
  border-radius: 16px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10);
}

.auth-logo { font-size: 2.5rem; margin-bottom: 8px; }

.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #111111;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-card input {
  width: 100%;
  padding: 13px 16px;
  background: #fafafa;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-card input:focus { border-color: var(--accent); background: #fff; }

.remember-row {
  display: flex;
  align-items: center;
  margin: -2px 0 14px 2px;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.remember-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: #111111;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: #333333; }
.btn-primary:active { transform: scale(0.99); }

.auth-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}

.auth-message.success { background: rgba(0,133,62,0.08); color: var(--accent); border: 1px solid rgba(0,133,62,0.2); }
.auth-message.error { background: rgba(192,57,43,0.08); color: var(--accent-red); border: 1px solid rgba(192,57,43,0.2); }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: #111111;
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: #00853E;
}

.sidebar-logo .logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.sidebar-logo .logo-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  margin-top: 3px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #ffffff; border-left-color: rgba(255,255,255,0.2); }
.nav-item.active { background: rgba(0,133,62,0.18); color: #5ddb8a; border-left-color: var(--accent); }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  background: #00853E;
}

.sidebar-footer .user-name { color: #ffffff; font-weight: 600; font-size: 0.85rem; }

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  margin-left: 240px;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
  min-height: 0;
  background: var(--page-bg);
}

/* ── Page Header ── */
.page { display: none; }
.page.active { display: block; }

.page-header { margin-bottom: 28px; }

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111111;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 0.88rem;
}

/* ── Cards ── */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #111111;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Metric Cards ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid #111111;
}

.metric-card .metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  font-weight: 500;
}

.metric-card .metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #111111;
  line-height: 1;
  letter-spacing: -0.02em;
}

.metric-card .metric-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.metric-card .metric-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 6px;
}

.badge-green { background: rgba(0,133,62,0.1); color: var(--accent); }
.badge-orange { background: rgba(224,123,0,0.1); color: var(--accent-orange); }
.badge-red { background: rgba(192,57,43,0.1); color: var(--accent-red); }
.badge-blue { background: rgba(77,25,121,0.1); color: var(--accent-purple); }

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  background: #fafafa;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }

/* ── Progress Bar ── */
.progress-bar {
  background: #f0f0f0;
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
  min-width: 80px;
}

.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.fill-green { background: var(--accent); }
.fill-orange { background: var(--accent-orange); }
.fill-red { background: var(--accent-red); }
.fill-blue { background: var(--accent-purple); }

/* ── Layout helpers ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }
}

/* ── Rep avatar ── */
.rep-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  margin-right: 10px;
  flex-shrink: 0;
}

.rep-name-cell { display: flex; align-items: center; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.tab {
  padding: 10px 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  font-weight: 500;
}

.tab:hover { color: #111111; }
.tab.active { color: #111111; border-bottom-color: #111111; font-weight: 600; }

/* ── Rank badge ── */
.rank { font-weight: 700; color: var(--text-muted); font-size: 0.875rem; }
.rank-1 { color: #b8860b; }
.rank-2 { color: #777; }
.rank-3 { color: #8B4513; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }

/* ── Buttons ── */
.btn-secondary {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover { border-color: #111111; color: #111111; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.report-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ── Chat Panel ── */
.chat-panel {
  height: 42vh;
  min-height: 200px;
  max-height: 80vh;
  background: #ffffff;
  border-top: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
}

.chat-resize-handle {
  height: 5px;
  background: var(--border);
  cursor: ns-resize;
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  z-index: 10;
  transition: background 0.15s;
}

.chat-resize-handle:hover { background: var(--accent); }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: #ffffff;
}

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

.chat-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111111;
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-header-actions { display: flex; gap: 8px; }

.chat-action-btn {
  background: none;
  border: 1px solid var(--border-dark);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chat-action-btn:hover { border-color: #111111; color: #111111; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}

.chat-message {
  display: flex;
  gap: 10px;
  max-width: 80%;
}

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

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.chat-message.mercury .chat-avatar { background: #f0f7f2; color: var(--accent); }
.chat-message.user .chat-avatar { background: #111111; color: #ffffff; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-message.mercury .chat-bubble {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 2px 12px 12px 12px;
  color: #111111;
  box-shadow: var(--shadow-sm);
}

.chat-message.user .chat-bubble {
  background: #111111;
  color: #ffffff;
  border-radius: 12px 2px 12px 12px;
}

.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 0;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-dark);
  animation: typing 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #ffffff;
}

.chat-input {
  flex: 1;
  background: #fafafa;
  border: 1px solid var(--border-dark);
  border-radius: 10px;
  padding: 10px 14px;
  color: #111111;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 40px;
  transition: border-color 0.2s;
  line-height: 1.4;
}

.chat-input:focus { border-color: #111111; background: #ffffff; }
.chat-input::placeholder { color: #aaaaaa; }

.chat-send-btn {
  background: #111111;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  font-size: 1rem;
  color: white;
}

.chat-send-btn:hover { background: #333333; }
.chat-send-btn:disabled { background: var(--border-dark); cursor: not-allowed; }

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
