/* VocalBill Styles - Based on UI Design Spec */

/* CSS Custom Properties */
:root {
  /* Primary */
  --color-primary: #2563EB;
  --color-primary-dark: #1D4ED8;
  --color-primary-light: #DBEAFE;

  /* Semantic */
  --color-success: #10B981;
  --color-success-light: #D1FAE5;
  --color-expense: #EF4444;
  --color-expense-light: #FEE2E2;
  --color-calendar: #8B5CF6;
  --color-calendar-light: #EDE9FE;
  --color-warning: #F59E0B;
  --color-error: #DC2626;

  /* Neutrals */
  --color-text-primary: #111827;
  --color-text-secondary: #374151;
  --color-text-muted: #6B7280;
  --color-border: #D1D5DB;
  --color-bg-section: #F3F4F6;
  --color-bg-page: #F9FAFB;
  --color-bg-card: #FFFFFF;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 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-voice-button: 0 8px 25px -5px rgba(37, 99, 235, 0.4);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;

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

  /* Easing */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg-page);
  color: var(--color-text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Typography Classes */
.text-display { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.text-h1 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.text-h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
.text-body-lg { font-size: 1.125rem; font-weight: 400; line-height: 1.5; }
.text-body { font-size: 1rem; font-weight: 400; line-height: 1.5; }
.text-body-sm { font-size: 0.875rem; font-weight: 400; line-height: 1.5; }
.text-caption { font-size: 0.75rem; font-weight: 500; line-height: 1.4; }

/* App Container */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Container */
.container {
  width: 100%;
  max-width: 100%;
  padding: 0 16px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .container {
    max-width: 600px;
    padding: 0 24px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 480px;
  }
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--color-text-primary);
}

.header__logo-icon {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

.header__settings {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-normal);
}

.header__settings:hover {
  background: var(--color-bg-section);
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px;
}

/* Voice Section */
.voice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 32px;
  gap: 16px;
}

/* Status Message */
.status-message {
  text-align: center;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-slow) ease;
}

.status-message--idle {
  color: var(--color-text-muted);
  background: transparent;
}

.status-message--listening {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.status-message--processing {
  color: var(--color-warning);
  background: #FEF3C7;
}

.status-message--success {
  color: var(--color-success);
  background: var(--color-success-light);
}

.status-message--error {
  color: var(--color-error);
  background: #FEE2E2;
}

/* Transcription Section */
.transcription-section {
  width: 100%;
  padding: 0 16px;
  margin-bottom: 16px;
}

.transcription-box {
  background: var(--color-bg-card);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  min-height: 80px;
  transition: all var(--transition-slow) ease;
}

.transcription-box--idle {
  border-color: var(--color-border);
}

.transcription-box--listening {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-light);
}

.transcription-box--has-content {
  border-color: var(--color-primary);
}

.transcription-box__placeholder {
  color: var(--color-text-muted);
  font-style: italic;
}

.transcription-box__text {
  color: var(--color-text-primary);
  font-size: 1.125rem;
  line-height: 1.5;
}

.transcription-box__parsed {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Blinking cursor for live transcription */
.transcription-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--color-primary);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}

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

/* Parsed Badges */
.parsed-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
}

.parsed-badge--expense {
  background: var(--color-expense-light);
  color: var(--color-expense);
}

.parsed-badge--income {
  background: var(--color-success-light);
  color: var(--color-success);
}

.parsed-badge--event {
  background: var(--color-calendar-light);
  color: var(--color-calendar);
}

.parsed-badge--note {
  background: var(--color-bg-section);
  color: var(--color-text-secondary);
}

/* Voice Button */
.voice-button-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-button {
  position: relative;
  z-index: 1;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-voice-button);
  transition: all var(--transition-normal) ease;
}

.voice-button__icon {
  width: 32px;
  height: 32px;
}

.voice-button__label {
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Voice Button States */
.voice-button--idle:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 30px -5px rgba(37, 99, 235, 0.5);
}

.voice-button--idle:active {
  transform: scale(0.98);
}

.voice-button--listening {
  animation: pulse-core 1.5s ease-in-out infinite;
}

@keyframes pulse-core {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Pulse rings */
.voice-button__ring {
  position: absolute;
  inset: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  animation: pulse-ring 1.5s ease-out infinite;
  pointer-events: none;
}

.voice-button__ring:nth-child(2) {
  animation-delay: 0.5s;
}

.voice-button__ring:nth-child(3) {
  animation-delay: 1s;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2); opacity: 0; }
}

.voice-button--processing {
  pointer-events: none;
  opacity: 0.9;
}

.voice-button--processing .voice-button__icon {
  animation: spin 1s linear infinite;
}

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

.voice-button--success {
  background: var(--color-success);
  box-shadow: 0 8px 25px -5px rgba(16, 185, 129, 0.4);
}

.voice-button--success .voice-button__icon {
  animation: checkmark-pop 0.4s ease-out;
}

@keyframes checkmark-pop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.voice-button--error {
  background: var(--color-error);
  box-shadow: 0 8px 25px -5px rgba(220, 38, 38, 0.4);
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@media (min-width: 768px) {
  .voice-button {
    width: 96px;
    height: 96px;
  }

  .voice-button__ring {
    width: 96px;
    height: 96px;
  }

  .voice-button__icon {
    width: 40px;
    height: 40px;
  }
}

/* Quick Actions */
.quick-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-normal) ease;
  font-family: inherit;
}

.quick-action:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.quick-action__icon {
  width: 16px;
  height: 16px;
}

/* Entries Section */
.entries-section {
  flex: 1;
  background: var(--color-bg-section);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 16px;
  min-height: 300px;
}

.entries-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.entries-section__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.entries-section__link {
  font-size: 0.875rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.entries-section__link:hover {
  text-decoration: underline;
}

/* Entry Groups */
.entry-group {
  margin-bottom: 20px;
}

.entry-group__date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* Entry Cards */
.entry-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-bg-card);
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal) ease;
}

.entry-card:hover {
  box-shadow: var(--shadow-md);
}

.entry-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.entry-card__icon svg {
  width: 20px;
  height: 20px;
}

.entry-card__icon--expense {
  background: var(--color-expense-light);
  color: var(--color-expense);
}

.entry-card__icon--income {
  background: var(--color-success-light);
  color: var(--color-success);
}

.entry-card__icon--event {
  background: var(--color-calendar-light);
  color: var(--color-calendar);
}

.entry-card__icon--note {
  background: var(--color-bg-section);
  color: var(--color-text-secondary);
}

.entry-card__content {
  flex: 1;
  min-width: 0;
}

.entry-card__title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-card__meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.entry-card__amount {
  font-size: 1rem;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
}

.entry-card__amount--expense {
  color: var(--color-expense);
}

.entry-card__amount--income {
  color: var(--color-success);
}

.entry-card__time {
  font-size: 0.875rem;
  color: var(--color-calendar);
  font-weight: 500;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  color: var(--color-text-muted);
  opacity: 0.5;
  margin-bottom: 16px;
}

.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.empty-state__description {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  max-width: 240px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  padding: 8px 16px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal) ease;
  text-decoration: none;
}

.bottom-nav__item:hover,
.bottom-nav__item--active {
  color: var(--color-primary);
}

.bottom-nav__item--active {
  background: var(--color-primary-light);
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
}

/* Touch-friendly sizing */
.touch-target {
  min-width: 44px;
  min-height: 44px;
}

/* Loading indicator for entries */
.loading-entries {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Utility classes */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive adjustments */
@media (min-width: 768px) {
  .voice-section {
    padding: 32px 24px 40px;
  }

  .transcription-section {
    padding: 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 24px;
  }

  .entries-section {
    padding: 24px 24px;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 24px;
    margin-bottom: 24px;
  }

  .quick-actions {
    margin-bottom: 32px;
  }
}
