/* =========================================================
   Blistex Analytics Dashboard — Shared Stylesheet
   ========================================================= */

/* --- Design tokens --- */
:root {
  --color-brand-primary: #c8102e;
  --color-brand-dark:    #8c0b20;
  --color-brand-light:   #f5e6e9;
  --color-surface:       #ffffff;
  --color-background:    #f2f4f7;
  --color-border:        #e0e3e8;
  --color-text:          #1a1a2e;
  --color-text-muted:    #6b7280;
  --color-error:         #d32f2f;
  --color-error-bg:      #fff0f0;
  --color-nav-bg:        #1a1a2e;
  --color-nav-text:      #c8d0e0;
  --color-nav-active:    #ffffff;
  --color-nav-indicator: #c8102e;

  --radius-card: 14px;
  --radius-btn:  8px;
  --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
  --transition:  0.2s ease;

  --header-height: 72px;
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--color-background);
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 420px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  display: block;
  margin: 0 auto 16px;
  max-width: 160px;
  height: auto;
}

.login-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

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

/* Form groups */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-group input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-group input:focus {
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

.form-group input::placeholder {
  color: #b0b7c3;
}

/* Error message */
.error-message {
  display: none;
  align-items: flex-start;
  gap: 8px;
  background: var(--color-error-bg);
  border-left: 3px solid var(--color-error);
  border-radius: 0 6px 6px 0;
  padding: 10px 12px;
  font-size: 0.8125rem;
  color: var(--color-error);
  margin-bottom: 16px;
  line-height: 1.45;
}

.error-message.visible {
  display: flex;
}

/* Submit button */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-brand-primary);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  letter-spacing: 0.01em;
  margin-top: 4px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-brand-dark);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Loading spinner inside button */
.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.btn-primary.loading .btn-text { opacity: 0.7; }
.btn-primary.loading .btn-spinner { display: block; }

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

/* =========================================================
   DASHBOARD PAGE
   ========================================================= */

.dashboard-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--color-background);
}

/* Header bar */
.dashboard-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  background: var(--color-nav-bg);
  padding: 0 16px 0 20px;
  flex-shrink: 0;
  gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-logo {
  max-width: 110px;
  height: auto;
  flex-shrink: 0;
  margin-right: 24px;
  filter: brightness(0) invert(1);
  opacity: 0.92;
}

/* Tab navigation */
.tab-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 1;
  height: 100%;
  overflow: hidden;
  min-width: 0;
}

.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: transparent;
  border: none;
  color: var(--color-nav-text);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
  height: 100%;
}

.tab-btn:hover {
  color: var(--color-nav-active);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn[aria-selected="true"] {
  color: var(--color-nav-active);
}

/* Active tab bottom indicator */
.tab-btn[aria-selected="true"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 3px;
  background: var(--color-nav-indicator);
  border-radius: 3px 3px 0 0;
}

/* Sign out button */
.logout-btn {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-btn);
  color: var(--color-nav-text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  white-space: nowrap;
}

.logout-btn:hover {
  border-color: rgba(255,255,255,0.5);
  color: var(--color-nav-active);
  background: rgba(255,255,255,0.07);
}

/* Dashboard content area */
.dashboard-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding: 30px;
  background: var(--color-background);
}

/* Module panels */
.panel {
  display: none;
  position: absolute;
  inset: 30px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.panel.active {
  display: block;
}

.panel iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Auth loading overlay */
.auth-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background);
  z-index: 999;
}

.auth-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* =========================================================
   404 PAGE
   ========================================================= */

.not-found-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.not-found-page h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.not-found-page p {
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

.not-found-page a {
  color: var(--color-brand-primary);
  font-weight: 600;
  text-decoration: none;
}

.not-found-page a:hover {
  text-decoration: underline;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 640px) {
  .login-card {
    padding: 28px 20px 24px;
  }

  .tab-btn {
    padding: 0 12px;
    font-size: 0.8125rem;
  }

  .header-logo {
    max-width: 80px;
    margin-right: 12px;
  }
}

/* Short labels hidden by default; only shown on very small screens */
.tab-btn span.short-label { display: none; }

@media (max-width: 480px) {
  .tab-btn span.label { display: none; }
  .tab-btn span.short-label { display: inline; }
}
