/* Base layout and common styles */

/* Material Symbols — self-hosted, subsetted to only the icons the app uses.
   NOTE: the subset was generated at one point in time and may be missing
   icons added later. If a new icon doesn't render, regenerate the subset
   from material-symbols-outlined-full.woff2. */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 100 700;
  font-display: block;
  src: url('../fonts/material-symbols-outlined.woff2') format('woff2');
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
}


/* CSS Variables - Design System */
:root {
  /* Colors - Primary */
  --color-primary: #E63946;
  --color-primary-dark: #D62839;
  --color-primary-light: #FF6B6B;

  /* Colors - Blue (Secondary) */
  --color-blue: #3e96ff;
  --color-blue-dark: #2b7de9;
  --color-blue-light: #6bb3ff;

  /* Colors - Neutral */
  --color-dark: #20212D;
  --color-dark-hover: #494A56;
  --color-gray-900: #1a1a2e;
  --color-gray-800: #2d2d44;
  --color-gray-700: #404058;
  --color-gray-600: #6b7280;
  --color-gray-500: #9ca3af;
  --color-gray-400: #c4c4c4;
  --color-gray-300: #d1d5db;
  --color-gray-200: #e5e7eb;
  --color-gray-100: #f3f4f6;
  --color-gray-50: #f9fafb;
  --color-white: #ffffff;

  /* Colors - Semantic */
  --color-success: #10B981;
  --color-success-light: #D1FAE5;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-error: #EF4444;
  --color-error-light: #FEE2E2;
  --color-info: #3B82F6;
  --color-info-light: #DBEAFE;

  /* Colors - Categories */
  --color-category-insurance: #10B981;
  --color-category-housing: #8B5CF6;
  --color-category-vehicle: #06B6D4;
  --color-category-financial: #F59E0B;
  --color-category-family: #EC4899;
  --color-category-other: #6B7280;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Z-index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 500;
  --z-tooltip: 600;
  --z-toast: 700;
}

/* TB Brand Colors */
:root {
    /* Primary */
    --tb-dark: #20212D;
    --tb-border: #E5E5E5;
    --tb-white: #ffffff;
    --tb-blue: #3E96FF;
    --tb-red: #D33F49;
    --tb-green: #38B267;
    --tb-orange: #EEA207;
    --tb-purple: #AC5DFF;

    /* Secondary */
    --tb-dark-grey: #494A56;
    --tb-grey: #747474;
    --tb-light-grey: #C8C6C6;
    --tb-blue-light: #B9D9FF;
    --tb-pink: #3E96FF;
    --tb-green-light: #C2F6D6;
    --tb-yellow-light: #FEEBC3;
    --tb-purple-light: #E2CBFF;

    /* Backgrounds */
    --tb-bg: #fafafa;
    --tb-background: #fafafa;
    --tb-pink-bg: #F8E8E8;
    --tb-green-bg: rgba(56,178,103,0.2);
    --tb-red-bg: rgba(211,63,73,0.2);
    --tb-orange-bg: rgba(238,162,7,0.2);
    --tb-grey-bg: rgba(200,198,198,0.25);
    --tb-blue-bg: rgba(62,150,255,0.2);
}

/* Body and main layout */
html, body {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: auto;
  background-color: #fff;
}

/* ===========================================
   WEBVIEW TOUCH OPTIMIZATIONS — native feel
   Only applied inside .webview-mode
   =========================================== */
.webview-mode * {
  -webkit-tap-highlight-color: transparent;
}
.webview-mode {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
}

.webview-mode a,
.webview-mode button,
.webview-mode [onclick],
.webview-mode [role="button"] {
  touch-action: manipulation;
}

.webview-mode .tb-btn, .webview-mode .cd-tab,
.webview-mode .quick-topic-chip, .webview-mode .topic-card,
.webview-mode .cd-stat-card, .webview-mode .cd-category-badge,
.webview-mode .cd-tag-pill, .webview-mode .sidebar-link,
.webview-mode .tb-bell-btn, .webview-mode .chat-clear-btn {
  -webkit-user-select: none;
  user-select: none;
}

.main-layout {
  position: relative;
  min-height: 100vh;
}

.main-layout::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: #ECECEC;
  background-image: var(--app-bg-image, none);
  background-size: cover;
  background-position: center;
  opacity: var(--app-bg-opacity, 0.75);
}

/* WebView mode: no sidebar, full-width content, safe areas for mobile */
/* Background is handled by the native app — make web bg transparent */
.main-layout.webview-mode::before {
  display: none;
}

body:has(.webview-mode) {
  background-color: transparent;
}

.main-layout.webview-mode .main-content-wrapper {
  margin-left: 0;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.main-content-wrapper {
  min-height: 100vh;
  margin-left: 250px;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
}

.main-content {
  flex: 1;
  padding: 32px 48px 48px 48px;
}

/* Page Footer */
.page-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 20px 24px;
  text-align: center;
  width: 100%;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--tb-grey, #747474);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}

.footer-links a:hover {
  color: var(--tb-dark, #20212D);
}

.footer-divider {
  color: var(--tb-light-grey, #C8C6C6);
  font-size: 12px;
}

.footer-copyright {
  color: var(--tb-grey, #747474);
  font-size: 12px;
  margin: 0;
}
.footer-copyright a {
  color: inherit;
  text-decoration: none;
}
.footer-copyright a:hover {
  color: var(--tb-dark, #20212D);
}

/* Mobile hamburger menu button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1001;
  background: #20212D;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-toggle.hidden {
  opacity: 0;
  visibility: hidden;
}

.mobile-menu-toggle:hover {
  background: #494A56;
}

.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* Toast notification system */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #333;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  font-weight: 500;
  max-width: 300px;
  word-wrap: break-word;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.success {
  background: #28a745;
}

.toast.error {
  background: #dc3545;
}

.toast.info {
  background: #17a2b8;
}

.toast.warning {
  background: #ffc107;
  color: #333;
}

/* Drag and drop visual feedback - DISABLED (using specific dropzone instead) */
/* body.drag-over {
  background-color: rgba(0, 123, 255, 0.1);
}

body.drag-over::before {
  content: "Drop files here to upload";
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 123, 255, 0.9);
  color: white;
  padding: 20px 40px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  z-index: 1000;
  pointer-events: none;
} */

/* Modal styles */
.modal-input-group {
  margin: 16px 0;
}

.modal-input-group .form-input {
  border-radius: 10px;
  border: 1px solid var(--tb-border, #E5E5E5);
  padding: 12px 16px;
  font-size: 16px;
  font-family: inherit;
  background: var(--tb-bg, #FAFAFA);
  transition: border-color 0.15s, background 0.15s;
}

.modal-input-group .form-input:focus {
  outline: none;
  border-color: var(--tb-dark, #20212D);
  background: var(--tb-white, #fff);
}

.modal-cancel-btn {
  display: none;
}

.modal-confirm-btn {
  display: none;
}


/* Responsive design - mobile and landscape */
@media (max-width: 768px), (max-height: 500px) and (orientation: landscape) {
  .mobile-menu-toggle {
    display: block;
  }
  
  .main-content-wrapper {
    margin-left: 0;
  }
  
  .main-content {
    padding: 8px 12px 16px 12px;
    margin-top: 50px; /* Reduced space for mobile menu button */
  }

  .webview-mode .main-content {
    margin-top: 0;
  }
  
  .toast-container {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }
  
  .toast {
    max-width: none;
    font-size: 13px;
    padding: 10px 16px;
  }
  
  /* Reduce overall font sizes on mobile */
  body {
    font-size: 14px;
  }
  
  h1 {
    font-size: 24px;
    margin-bottom: 12px;
  }
  
  h2 {
    font-size: 20px;
    margin-bottom: 10px;
  }
  
  h3 {
    font-size: 18px;
    margin-bottom: 8px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 12px 16px 20px 16px;
  }
}

/* ===========================================
   COOKIE CONSENT BANNER
   =========================================== */
.tb-cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: var(--tb-dark, #20212D);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 16px 24px;
    /* Account for iOS Safari home indicator / Android nav bar */
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    animation: tbCookieSlideUp 0.3s ease;
    box-sizing: border-box;
    /* Cap height so banner never covers more than half the screen */
    max-height: 50vh;
    overflow-y: auto;
}
@keyframes tbCookieSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.tb-cookie-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.tb-cookie-text {
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.8);
    margin: 0;
    line-height: 1.5;
    flex: 1;
    min-width: 0;
}
.tb-cookie-link {
    color: var(--tb-blue, #3E96FF);
    text-decoration: underline;
    white-space: nowrap;
}
.tb-cookie-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.tb-cookie-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
    /* Minimum 44px touch target on mobile */
    min-height: 44px;
}
.tb-cookie-accept {
    background: var(--tb-blue, #3E96FF);
    color: #fff;
}
.tb-cookie-accept:hover {
    background: #2a7de8;
}
.tb-cookie-reject {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
}
.tb-cookie-reject:hover {
    background: rgba(255,255,255,0.15);
}
@media (max-width: 640px) {
    .tb-cookie-banner {
        padding: 14px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    }
    .tb-cookie-inner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 12px;
    }
    .tb-cookie-text {
        font-size: 0.8125rem;
    }
    .tb-cookie-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    .tb-cookie-btn {
        width: 100%;
        padding: 12px 16px;
    }
}
