/* ============================================
   SHARED UI STYLES
   Common styles used across all UIs
   ============================================ */

/* === CSS CUSTOM PROPERTIES === */
:root {
  --sidebar-width: 346px;
  --content-top-spacing: 40px;
  
  /* Black & Gray Palette */
  --bg: #121212;
  --bg-2: #1a1a1a;
  --bg-layer-1: #232323;
  --bg-layer-2: #2d2d2d;
  --text: #f5f5f5;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --muted: #b0b0b0;
  --accent: #e8e8e8;
  --border: #2d2d2d;
  --sidebar-subtext: #b0b0b0;

  /* Typography - Font Families */
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Epilogue', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Typography - Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Typography - Font Sizes */
  --font-size-xs: 0.7rem;      /* 11.2px - tiny labels */
  --font-size-sm: 0.75rem;     /* 12px - small labels, captions */
  --font-size-base: 0.85rem;   /* 13.6px - standard UI text */
  --font-size-md: 0.9rem;      /* 14.4px - body text, inputs */
  --font-size-lg: 1rem;        /* 16px - emphasized text */
  --font-size-xl: 1.1rem;      /* 17.6px - card titles */
  --font-size-2xl: 1.25rem;    /* 20px - h3, section headers */
  --font-size-3xl: 1.5rem;     /* 24px - h2, modal headers */
  --font-size-4xl: 2rem;       /* 32px - h1, page headers */
  
  /* Typography - Line Heights */
  --line-height-tight: 1.2;
  --line-height-snug: 1.4;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;
  
  /* Typography - Letter Spacing */
  --letter-spacing-tight: -0.01em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.05em;
  --letter-spacing-wider: 0.1em;
  --letter-spacing-widest: 0.18em;
  
  /* Border Radius Standards */
  --radius-sm: 0;
  --radius-md: 0;
  --radius-lg: 0;
  --radius-pill: 0;
  
  /* Icon Sizes */
  --icon-sm: 18px;
  --icon-md: 20px;
  --icon-lg: 24px;
  
  /* Spacing Scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
}

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

html, body { 
  height: 100%; 
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  height: 100vh;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #333333 var(--bg);
}

/* === TYPOGRAPHY - HEADINGS === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--accent);
  margin: 0;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

h1 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
}

h2 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
}

h3 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
}

h4 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

h5 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
}

h6 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
}

/* === SCROLLBAR STYLING === */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--bg);
}

*::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg);
}

*::-webkit-scrollbar-thumb:hover {
  background: #444444;
}

/* === MAIN LAYOUT === */
.main-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  transition: padding-left 0.2s ease;
}

.main-container.sidebar-collapsed {
  padding-left: 0;
}

/* === SIDEBAR === */
.sidebar {
  position: relative;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-basis: var(--sidebar-width);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  color: var(--text);
  padding: 2.5rem 0.5rem 0.75rem 0.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: width 0.2s ease, flex-basis 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: #333333 var(--bg-2);
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--bg-2);
}

.sidebar::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: var(--radius-sm);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #444444;
}

.main-container.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  flex-basis: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-section {
  background: transparent;
  border: none;
  border-bottom: none;
  border-radius: 0;
  padding: 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.section-title {
  text-transform: uppercase;
  font-size: var(--font-size-sm);
  letter-spacing: var(--letter-spacing-widest);
  color: var(--text-secondary);
  padding: 0.25rem 0;
  font-weight: var(--font-weight-medium);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

/* === ACCOUNT SECTION === */
.account-section {
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.account-email {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: #e5e9f0;
  word-break: break-all;
  text-align: center;
}

.logout-form {
  margin-top: 0.25rem;
}

.logout-button {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 0;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background 0.2s ease;
  text-align: center;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* === NAVIGATION LINKS === */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-normal);
  border: none;
  border-left: 2px solid transparent;
  position: relative;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-link.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: rgba(255, 255, 255, 0.03);
}

.nav-link .material-icons {
  font-size: 20px;
}

.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === SIDEBAR TOGGLE === */
.sidebar-toggle {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  width: 32px;
  height: 32px;
  border-radius: 0;
  background: var(--bg-2);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 11;
  color: var(--text);
  padding: 0;
}

.sidebar-toggle:hover {
  opacity: 0.8;
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-toggle-icon {
  font-size: 18px;
}

/* When sidebar is open, position toggle inside sidebar at top-left */
.main-container:not(.sidebar-collapsed) .sidebar-toggle {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
}

.main-container:not(.sidebar-collapsed) .sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* === SIDEBAR BACKDROP === */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 19;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

/* === CONTENT AREA === */
.content-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--content-top-spacing);
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  width: 100%;
}

.content-container {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

/* === BUTTONS === */
.btn-icon {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon .material-icons {
  font-size: 18px;
}

.btn-icon:hover { 
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-danger-small {
  width: 100%;
  background: rgba(136, 136, 136, 0.1);
  border: 1px solid rgba(136, 136, 136, 0.2);
  color: #888888;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-xs);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.btn-danger-small .material-icons {
  font-size: 16px;
}

.btn-danger-small:hover {
  background: rgba(136, 136, 136, 0.2);
  border-color: rgba(136, 136, 136, 0.4);
}

.btn-danger-small:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* === MOBILE RESPONSIVENESS === */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: 403px;
    min-width: 403px;
    max-width: 85vw;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .main-container:not(.sidebar-collapsed) .sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .main-container.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-toggle {
    position: fixed !important;
    z-index: 21;
    display: flex !important;
    /* Ensure touch target meets 44×44px minimum */
    min-width: 44px;
    min-height: 44px;
  }

  .main-container.sidebar-collapsed .sidebar-toggle {
    position: fixed !important;
    top: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    background: rgba(20, 20, 20, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    opacity: 1;
  }

  .main-container:not(.sidebar-collapsed) .sidebar-toggle {
    position: absolute !important;
    top: 0.75rem;
    left: 0.75rem !important;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid var(--border);
    opacity: 0.7;
  }

  .main-container:not(.sidebar-collapsed) .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
  }

  .sidebar-toggle-icon {
    font-size: 20px;
  }
  
  /* Ensure nav links and buttons meet touch target requirements */
  .nav-link {
    min-height: 44px;
  }
  
  .logout-button {
    min-height: 44px;
  }
}

/* === iOS SAFE AREA INSETS === */
@supports (-webkit-touch-callout: none) {
  /* Safe area handling for iOS devices with notches */
  .content-area {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
  }
  
  .sidebar {
    padding-top: calc(2.5rem + env(safe-area-inset-top, 0));
  }
  
  /* Prevent iOS zoom on input focus */
  input[type="text"],
  input[type="email"],
  textarea,
  select {
    font-size: 16px;
  }

  /* Responsive heading sizes for tablet/mobile */
  h1 {
    font-size: var(--font-size-3xl);
  }

  h2 {
    font-size: var(--font-size-2xl);
  }

  h3 {
    font-size: var(--font-size-xl);
  }
}

/* === SMALL PHONES (480px and below) === */
@media (max-width: 480px) {
  h1 {
    font-size: var(--font-size-2xl);
  }

  h2 {
    font-size: var(--font-size-xl);
  }

  h3 {
    font-size: var(--font-size-lg);
  }
}

/* === TYPOGRAPHY UTILITY CLASSES === */

/* Font size utilities */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }
.text-4xl { font-size: var(--font-size-4xl); }

/* Font weight utilities */
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* Text color utilities */
.text-primary { color: var(--text); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }

/* Letter spacing utilities */
.tracking-tight { letter-spacing: var(--letter-spacing-tight); }
.tracking-normal { letter-spacing: var(--letter-spacing-normal); }
.tracking-wide { letter-spacing: var(--letter-spacing-wide); }
.tracking-wider { letter-spacing: var(--letter-spacing-wider); }
.tracking-widest { letter-spacing: var(--letter-spacing-widest); }

/* Line height utilities */
.leading-tight { line-height: var(--line-height-tight); }
.leading-snug { line-height: var(--line-height-snug); }
.leading-normal { line-height: var(--line-height-normal); }
.leading-relaxed { line-height: var(--line-height-relaxed); }

/* Common text patterns */
.eyebrow {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-widest);
  color: var(--text-secondary);
}

.label-text {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
}

.caption {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  line-height: var(--line-height-snug);
}

.mono {
  font-family: var(--font-mono);
}

/* === GOOGLE ACCOUNTS SECTION === */
.google-accounts-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.google-accounts-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.google-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: #666666 #111111;
  padding-right: 4px;
}

.google-accounts-list::-webkit-scrollbar {
  width: 10px;
}

.google-accounts-list::-webkit-scrollbar-track {
  background: #0f0f0f;
  border-radius: 5px;
}

.google-accounts-list::-webkit-scrollbar-thumb {
  background: #666666;
  border-radius: 5px;
}

.google-accounts-list::-webkit-scrollbar-thumb:hover {
  background: #777777;
}

.expand-collapse-button {
  background: transparent;
  border: none;
  color: var(--sidebar-subtext);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, color 0.2s ease;
  border-radius: var(--radius-sm);
}

.expand-collapse-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.expand-collapse-button.expanded {
  transform: rotate(180deg);
}

.loading-accounts {
  font-size: var(--font-size-sm);
  color: var(--sidebar-subtext);
  padding: 0.5rem;
}

.account-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  gap: 0.5rem;
}

.account-item-info {
  flex: 1;
  min-width: 0;
}

.account-item-email {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-item-label {
  font-size: var(--font-size-xs);
  color: var(--sidebar-subtext);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

.account-item-primary {
  color: var(--accent);
}

.remove-account-button {
  padding: 0.25rem 0.5rem;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 100, 100, 0.3);
  background: rgba(255, 100, 100, 0.1);
  color: #ffaaaa;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-account-button:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgba(255, 100, 100, 0.5);
}

.remove-account-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.add-account-button {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #d8dbe2;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-account-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

