/* css/main.css */

/* --- 1. RESET & BASE --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* --- 2. ACCESSIBILITY --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  z-index: 10000;
  font-weight: 700;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus { top: 0; }

*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- 3. HEADER --- */
.app-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo span { color: var(--accent); }
.logo:hover { opacity: 0.9; }

.nav-links { display: flex; gap: 1.5rem; }

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.nav-link:hover, .nav-link.active { color: var(--accent); }

.header-controls { display: flex; align-items: center; gap: 1rem; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  /* Add a subtle shadow for depth on hover */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0);
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  /* Lift effect */
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.icon-btn:active {
  transform: translateY(0);
  background: var(--surface);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Ensure SVG scales correctly */
.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: stroke 0.2s ease;
}

/* --- 4. THEME TOGGLE --- */
.theme-toggle-group {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.theme-opt {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.3rem 0.6rem;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.theme-opt:hover { color: var(--text); }

.theme-opt.active {
  background: var(--surface-hover);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* --- 5. AUTH & DROPDOWN --- */
.auth-buttons { display: flex; align-items: center; gap: 0.75rem; }

.btn-text {
  /* Remove default link styling */
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;

  /* Professional Button Styling */
  padding: 0.4rem 1rem;
  border-radius: 20px; /* Pill shape */
  background: transparent;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Hover State: Subtle background lift */
.btn-text:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}

/* Active/Pressed State */
.btn-text:active {
  transform: translateY(0);
  background: var(--surface);
  border-color: var(--border);
}

/* Optional: Add a subtle icon if you want (e.g., a user icon) */
/* You can add this inside the HTML: <svg>...</svg> before the text */
.btn-text svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  transition: stroke 0.2s;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
}

.user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.auth-dropdown {
  position: absolute;
  right: 0;
  top: 45px;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  overflow: hidden;
  animation: dropdownFade 0.15s ease-out;
  display: none;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-user-info {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
}

.dropdown-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.dropdown-email {
  font-size: 0.75rem;
  color: var(--text-dim);
  word-break: break-all;
}

.dropdown-logout {
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.dropdown-logout:hover { background: var(--red-bg); }

/* Mobile Header Adjustments */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .nav-links { display: none; }
  .auth-buttons { margin-left: auto; }
}

/* --- 6. MAIN LAYOUT --- */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

@media (max-width: 800px) {
  .content-grid { grid-template-columns: 1fr; }
}

/* --- 7. CARDS --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 2px var(--shadow);
  transition: border-color 0.2s, background-color 0.3s;
}

.card:hover { border-color: var(--accent); }

.card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }
.card-value.neutral { color: var(--blue); }

/* --- 8. FOOTER --- */
footer {
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  background: var(--surface);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  transition: background-color 0.3s, border-color 0.3s;
}

.footer-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0;
}

.footer-btn-pill {
  background: var(--accent);
  color: #fff;
  padding: 0.25rem 0.85rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.footer-btn-pill:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.footer-link {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
  padding: 0.25rem 0;
  font-size: 0.8rem;
  font-weight: 500;
}

.footer-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-dot {
  color: var(--border);
  margin: 0 0.75rem;
  user-select: none;
  font-size: 0.8rem;
}

.copyright-text {
  font-size: 0.75rem;
  line-height: 1.4;
}

@media (max-width: 600px) {
  footer { padding: 1.5rem 1rem; }
  .footer-main { flex-direction: column; gap: 0.5rem; }
  .footer-dot { display: none; }
  .footer-btn-pill { margin-bottom: 0.5rem; }
}

/* --- THEME TOGGLE SUBTLE PULSE ANIMATION --- */

/* Define the gentle pulse */
@keyframes themePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 247, 0); /* Fully transparent */
  }
  50% {
    /* Subtle purple glow matching your accent color */
    box-shadow: 0 0 0 3px rgba(139, 92, 247, 0.15);
  }
}

/* Apply to the active theme button */
.theme-opt.active {
  /* Existing styles */
  background: var(--surface-hover);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);

  /* Add the subtle pulse */
  animation: themePulse 4s ease-in-out infinite;
}

/* Optional: Pause animation when user hovers so it doesn't interfere with clicking */
.theme-opt:hover {
  animation-play-state: paused;
}
