@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #080c14;
  --bg-secondary: rgba(20, 30, 48, 0.65);
  --border-glow: rgba(255, 255, 255, 0.08);
  --border-glow-active: rgba(99, 102, 241, 0.3);
  
  --color-primary: #6366f1; /* Neon Purple/Indigo */
  --color-primary-glow: rgba(99, 102, 241, 0.15);
  --color-secondary: #0ea5e9; /* Electric Blue/Teal */
  --color-secondary-glow: rgba(14, 165, 233, 0.15);
  
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

html, body {
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding: 2rem 1rem;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--color-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  font-size: 2.2rem;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.connections {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.status-badge:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.02);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 4px currentColor;
}

.status-indicator.connected {
  background: var(--color-success);
  color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.status-indicator.error {
  background: var(--color-danger);
  color: var(--color-danger);
  box-shadow: 0 0 8px var(--color-danger);
}

/* Main Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 420px 1fr;
  }
}

/* Glass Panel Base */
.glass-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.37);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.glass-panel h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-glow);
  padding-bottom: 0.75rem;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.04);
  box-shadow: inset 0 0 10px rgba(99, 102, 241, 0.05);
}

.dropzone-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
}

.dropzone p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.dropzone strong {
  color: var(--color-secondary);
}

#file-input {
  display: none;
}

/* Preview Section */
.preview-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glow);
  display: none;
}

.preview-image {
  width: 100%;
  height: auto;
  display: block;
  max-height: 300px;
  object-fit: contain;
  background: #000;
}

.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.preview-container.scanning .preview-overlay {
  opacity: 1;
}

.scan-laser {
  width: 100%;
  height: 4px;
  background: linear-gradient(to right, transparent, var(--color-secondary), transparent);
  box-shadow: 0 0 15px var(--color-secondary);
  position: absolute;
  top: 0;
  animation: laser-bounce 2s infinite linear;
}

@keyframes laser-bounce {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Buttons */
.btn {
  width: 100%;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 4px 15px var(--color-primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--color-secondary) 0%, #0284c7 100%);
  color: #fff;
  box-shadow: 0 4px 15px var(--color-secondary-glow);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-glow);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-icon-only {
  width: auto;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
  background: rgba(255, 255, 255, 0.08);
}

select option {
  background: #0f172a;
  color: #fff;
}

/* Receipt Details Table Area */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glow);
  background: rgba(255, 255, 255, 0.01);
  max-height: 320px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-glow);
}

th {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 10;
}

tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.action-cell {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-danger-text {
  background: transparent;
  color: var(--color-danger);
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-danger-text:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Analytics Row */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 850px) {
  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 250px;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Settings Drawer/Modal */
.drawer {
  position: fixed;
  top: 0;
  right: -450px;
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  padding: 2rem;
  overflow-y: auto;
  border-left: 1px solid var(--border-glow);
  transition: right 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-glow);
  padding-bottom: 1rem;
}

.close-drawer {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
}

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
}

.overlay.visible {
  display: block;
}

/* Help Box UI */
.help-box {
  background: rgba(99, 102, 241, 0.05);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.help-box summary {
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.help-box ol {
  margin-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Inline Loading / Success logs */
.progress-log {
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  gap: 0.25rem;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.log-entry.active {
  color: var(--color-secondary);
}

.log-entry.done {
  color: var(--color-success);
}

.total-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
}

.total-summary h3 {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 1rem;
}

.total-summary p {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-secondary);
}

/* SweetAlert2 Theme Custom Overrides */
.swal-custom-popup {
  font-family: var(--font-family) !important;
  border-radius: var(--radius-lg) !important;
  border: 1px solid var(--border-glow) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8) !important;
}

.swal-logs-popup {
  max-width: 650px !important;
  padding: 12px 12px 12px 12px !important;
}

.swal-logs-popup .swal2-html-container {
  margin: 8px 0 0 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.swal-logs-popup .swal2-title {
  padding: 0 !important;
  margin: 0 !important;
}

.swal-logs-popup .swal2-actions {
  margin: 12px 0 0 0 !important;
}

.swal-custom-popup .btn {
  margin: 0.5rem;
  width: auto !important;
  display: inline-flex !important;
}

.swal-custom-popup .swal2-input.swal-custom-input {
  width: 90% !important;
  padding: 0.75rem !important;
  height: auto !important;
  border-radius: var(--radius-md) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border-glow) !important;
  color: var(--text-main) !important;
  font-family: var(--font-family) !important;
  font-size: 0.95rem !important;
  box-shadow: none !important;
  margin: 1rem auto !important;
  box-sizing: border-box !important;
}

.swal-custom-popup .swal2-input.swal-custom-input:focus {
  border-color: var(--color-primary) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  outline: none !important;
}



#btn-show-logs {
  display: none !important;
}

/* Custom Select Style with Google Sheets Logo */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  font-family: var(--font-family);
  width: auto;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.custom-select-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.custom-select-trigger .arrow-indicator {
  margin-left: 4px;
  font-size: 0.7rem;
  opacity: 0.7;
  transition: transform 0.3s ease;
}

.custom-select-wrapper.open .custom-select-trigger .arrow-indicator {
  transform: rotate(180deg);
}

.custom-options {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #0f172a;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  z-index: 100;
  min-width: 240px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 4px 0;
  overflow-y: auto;
  max-height: 200px;
}

.custom-select-wrapper.open .custom-options {
  display: block;
}

.custom-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.2s ease;
}

.custom-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.custom-option.selected {
  background: var(--color-primary-glow);
  color: var(--color-secondary);
}

.sheets-logo-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Mobile responsive layout overrides */
@media (max-width: 600px) {
  header {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    align-items: center !important;
    row-gap: 1rem !important;
    column-gap: 1rem !important;
  }
  
  header .brand {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  
  header #btn-settings {
    grid-column: unset !important;
    grid-row: unset !important;
    justify-self: unset !important;
    margin: 0 !important;
  }

  header .action-buttons-group {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    display: flex !important;
    gap: 8px;
    margin: 0 !important;
  }

  #btn-show-logs {
    display: inline-flex !important;
  }

  #panel-logs {
    display: none !important;
  }
  
  header .header-actions {
    display: contents !important;
  }
  
  header .connections {
    grid-column: 1 / span 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }
  
  header #btn-google-auth {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
  }
  
  /* Form row stacks on mobile */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* Make settings drawer fully mobile responsive */
  .drawer {
    max-width: 100% !important;
    right: -100%;
  }
  
  .drawer.open {
    right: 0 !important;
  }
}
