/* ==========================================================================
   Zdawator - CSS Design System & Layout
   Theme: AMOLED Black (#000000) & Rich Copper-Brown (#a67c52)
   ========================================================================== */

:root {
  --color-amoled: #000000;
  --color-card-bg: #0d0a08;
  --color-card-border: #2c1e15;
  --color-accent-brown: #a67c52;
  --color-accent-light: #c69c6d;
  --color-accent-dark: #8a5d38;
  --color-accent-dim: #3d2b1f;
  --color-text-primary: #f4efe9;
  --color-text-secondary: #a39c94;
  --color-text-muted: #5e5751;
  --color-error: #cf6679;
  --color-success: #4caf50;
  
  --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
}

/* Base resets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #050505;
  color: var(--color-text-primary);
  font-family: var(--font-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* ==========================================================================
   Desktop Mockup / App Container
   ========================================================================== */
.phone-frame {
  width: 100%;
  height: 100dvh;
  max-width: 100%;
  position: relative;
  background-color: var(--color-amoled);
  overflow: hidden;
}

/* Standard desktop view (simulates mobile screen) */
@media (min-width: 500px) {
  body {
    background-color: #12100e;
    background-image: radial-gradient(circle at 10% 20%, rgba(166, 124, 82, 0.08) 0%, transparent 60%);
  }
  
  .phone-frame {
    width: 412px;
    height: 840px;
    border-radius: 40px;
    border: 10px solid #221b16;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 40px rgba(166, 124, 82, 0.15);
    max-height: 95vh;
  }
}

#app-container {
  width: 100%;
  height: 100%;
  position: relative;
  background-color: var(--color-amoled);
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Screen General Rules
   ========================================================================== */
.app-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--color-amoled);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 10;
  overflow: hidden;
}

.app-screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 20;
}

.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 24px;
  scrollbar-width: none;
}
.scroll-content::-webkit-scrollbar {
  display: none;
}

/* ==========================================================================
   Typography & Elements
   ========================================================================== */
.app-header {
  padding: 24px 20px 10px 20px;
  text-align: center;
  border-bottom: 1px solid var(--color-card-border);
}

.logo {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--color-text-primary) 0%, var(--color-accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(166, 124, 82, 0.2);
}

.subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-accent-brown);
  margin-top: 4px;
  font-weight: 600;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

p {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent-dark) 0%, var(--color-accent-brown) 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(166, 124, 82, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(166, 124, 82, 0.2);
}

.btn-primary:disabled {
  background: var(--color-accent-dim);
  color: var(--color-text-muted);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary {
  background: var(--color-card-bg);
  border: 1px solid var(--color-accent-brown);
  color: var(--color-accent-light);
}

.btn-secondary:active {
  background: var(--color-accent-dim);
}

.btn-icon-text {
  background: transparent;
  border: none;
  color: var(--color-accent-light);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.btn-icon-text:active {
  opacity: 0.7;
}

.btn-text-danger {
  background: transparent;
  border: none;
  color: var(--color-error);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

/* Form Controls */
.form-select, .form-input {
  width: 100%;
  background-color: #080605;
  border: 1px solid var(--color-card-border);
  color: var(--color-text-primary);
  border-radius: var(--border-radius-sm);
  padding: 10px 12px;
  font-family: var(--font-primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.form-select:focus, .form-input:focus {
  border-color: var(--color-accent-brown);
  box-shadow: 0 0 8px rgba(166, 124, 82, 0.2);
}

.select-wrapper {
  position: relative;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

textarea.form-input {
  resize: none;
}

/* Cards */
.config-card {
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--border-radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.margin-top-sm {
  margin-top: 10px;
}

.prompt-preview-box {
  background-color: #070504;
  border: 1px dashed var(--color-card-border);
  border-radius: var(--border-radius-sm);
  padding: 12px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-secondary);
  max-height: 90px;
  overflow-y: auto;
  word-break: break-word;
}

.status-warning {
  color: var(--color-accent-brown);
  font-weight: 500;
}
.status-ready {
  color: var(--color-success);
  font-weight: 500;
}

/* Switch styling */
.switch-container {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch-container input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #221b16;
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--color-card-border);
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--color-text-secondary);
  transition: .3s;
  border-radius: 50%;
}
input:checked + .switch-slider {
  background-color: var(--color-accent-brown);
}
input:checked + .switch-slider:before {
  transform: translateX(20px);
  background-color: #ffffff;
}

.camera-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

/* Action Footer */
.action-footer {
  position: relative;
  padding: 12px 20px 24px 20px;
  background-color: var(--color-amoled);
  border-top: 1px solid var(--color-card-border);
  z-index: 30;
}

/* ==========================================================================
   Screen 2: Camera Capture
   ========================================================================== */
.screen-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--color-card-border);
  background-color: var(--color-amoled);
}

.btn-back {
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}
.btn-back:active {
  background-color: var(--color-card-bg);
}

.screen-header h2 {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-prompt-badge {
  background-color: var(--color-accent-dim);
  border: 1px solid var(--color-accent-brown);
  color: var(--color-accent-light);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-viewport-container {
  flex: 1 1 0%;
  min-height: 160px;
  background-color: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--color-card-border);
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#camera-overlay-message {
  position: absolute;
  color: var(--color-text-secondary);
  font-size: 14px;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--color-card-border);
}

/* Thumbnails list style */
.thumbnails-bar {
  background-color: #070504;
  border-bottom: 1px solid var(--color-card-border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thumbnails-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.thumbnails-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  min-height: 70px;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent-dim) transparent;
}

.thumbnails-list::-webkit-scrollbar {
  height: 4px;
}
.thumbnails-list::-webkit-scrollbar-thumb {
  background: var(--color-accent-dim);
  border-radius: 4px;
}

.thumbnail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  width: 100%;
  gap: 6px;
  font-size: 11px;
}

.thumbnail-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--border-radius-sm);
  border: 1.5px solid var(--color-accent-brown);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background-color: rgba(207, 102, 121, 0.9);
  color: #fff;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Camera Controls Layout */
.camera-controls {
  height: 120px;
  background-color: var(--color-amoled);
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  padding: 12px 20px 32px 20px; /* Raised layout by adding 32px bottom padding */
  position: relative;
}

.btn-shutter {
  width: 82px; /* Increased from 68px */
  height: 82px; /* Increased from 68px */
  border-radius: 50%;
  background-color: transparent;
  border: 4px solid var(--color-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
}

.btn-shutter:active {
  transform: scale(0.92);
}

.shutter-inner {
  width: 64px; /* Increased from 52px */
  height: 64px; /* Increased from 52px */
  border-radius: 50%;
  background-color: var(--color-accent-brown);
  box-shadow: 0 0 12px rgba(166, 124, 82, 0.5);
  transition: var(--transition-smooth);
}

.btn-shutter:active .shutter-inner {
  background-color: var(--color-accent-light);
  transform: scale(0.9);
}

.btn-submit-photos {
  min-width: 130px;
  height: 48px; /* Slightly taller for better touch target */
}

/* ==========================================================================
   Screen 3: Lock & AutoScroll Response
   ========================================================================== */
#screen-lock {
  background-color: #000000;
}

/* Unlocked Mode Nav Buttons */
.btn-lock-nav {
  position: absolute;
  top: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: rgba(13, 10, 8, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-accent-brown);
  color: var(--color-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  outline: none;
  transition: var(--transition-smooth);
}

.btn-lock-nav:active {
  transform: scale(0.92);
  background-color: var(--color-accent-dim);
}

.btn-lock-back {
  left: 20px;
}

.unlocked-controls-wrapper {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100;
}

.margin-control-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(13, 10, 8, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-accent-brown);
  border-radius: 24px;
  padding: 0 14px;
  height: 46px;
  color: var(--color-accent-light);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

#margin-slider {
  -webkit-appearance: none;
  width: 70px;
  height: 4px;
  background: #2c1e15;
  border-radius: 2px;
  outline: none;
}

#margin-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent-brown);
  cursor: pointer;
  transition: var(--transition-smooth);
}

#margin-slider::-webkit-slider-thumb:active {
  background: var(--color-accent-light);
  transform: scale(1.2);
}

.btn-lock-nav-relock {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: rgba(13, 10, 8, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-accent-brown);
  color: var(--color-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  outline: none;
  transition: var(--transition-smooth);
  animation: glowPulse 2s ease-in-out infinite alternate;
}

.btn-lock-nav-relock:active {
  transform: scale(0.92);
  background-color: var(--color-accent-dim);
}

.btn-lock-nav-reset {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: rgba(13, 10, 8, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-error);
  color: var(--color-error);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  outline: none;
  transition: var(--transition-smooth);
}

.btn-lock-nav-reset:active {
  transform: scale(0.92);
  background-color: rgba(207, 102, 121, 0.15);
}

/* Loading display while API running */
.lock-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 40;
  background-color: #000000;
  padding: 30px;
  text-align: center;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(166, 124, 82, 0.1);
  border-top-color: var(--color-accent-brown);
  border-radius: 50%;
  animation: spin 1s linear infinite, glowPulse 2s ease-in-out infinite alternate;
  margin-bottom: 24px;
}

.lock-loader-overlay h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.lock-loader-overlay p {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Autoscroll Response Area */
.response-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  background-color: #000000;
  overflow: hidden;
}

.response-scroller {
  width: 100%;
  height: 100%;
  padding: 100px 64px 80px 64px; /* Even larger side margins for focused layout */
  scrollbar-width: none;
}
.response-scroller.is-locked {
  overflow: hidden;
}
.response-scroller.is-unlocked {
  overflow-y: auto;
}
.response-scroller::-webkit-scrollbar {
  display: none;
}

.response-text {
  color: #ffffff;
  font-size: 18px;
  line-height: 1.7;
  font-weight: 400;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.95;
  text-shadow: 0 0 1px rgba(255,255,255,0.2);
}

/* Style formatting for AI response (markdown sub-elements) */
.response-text p {
  color: #ffffff;
  font-size: 18px;
  margin-bottom: 10px; /* Reduced paragraph spacing */
  line-height: 1.7;
}

.response-text h1, .response-text h2, .response-text h3 {
  color: var(--color-accent-light);
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 700;
}
.response-text h1 { font-size: 22px; }
.response-text h2 { font-size: 20px; }
.response-text h3 { font-size: 18px; }

.response-text ul, .response-text ol {
  margin-left: 20px;
  margin-bottom: 10px; /* Reduced list spacing */
}
.response-text li {
  margin-bottom: 8px;
}

.response-text code {
  font-family: var(--font-mono);
  background-color: #16120e;
  color: var(--color-accent-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 15px;
}

.response-text pre {
  background-color: #0d0a08;
  border: 1px solid var(--color-card-border);
  padding: 14px;
  border-radius: var(--border-radius-sm);
  overflow-x: auto;
  margin-bottom: 16px;
}
.response-text pre code {
  background-color: transparent;
  padding: 0;
  color: #ffffff;
}

.scroll-spacer {
  height: 50vh; /* large empty height so that the text can completely scroll past the top */
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.modal-card {
  width: 100%;
  background-color: #070504;
  border-top: 2px solid var(--color-accent-brown);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px 20px;
  max-height: 85%;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}
.btn-close:active {
  background-color: var(--color-card-bg);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}
.modal-body::-webkit-scrollbar {
  display: none;
}

.modal-divider {
  border: 0;
  height: 1px;
  background-color: var(--color-card-border);
  margin: 20px 0;
}

.prompt-list-section h4 {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.modal-prompt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-prompt-item {
  background-color: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.modal-prompt-item:active {
  border-color: var(--color-accent-brown);
}

.modal-prompt-item.active {
  border-color: var(--color-accent-brown);
  background-color: var(--color-accent-dim);
}

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

.prompt-item-info h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.prompt-item-info p {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-delete-prompt {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}
.btn-delete-prompt:active {
  color: var(--color-error);
  background-color: rgba(207, 102, 121, 0.08);
}

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

@keyframes glowPulse {
  from {
    box-shadow: 0 0 10px rgba(166, 124, 82, 0.2);
  }
  to {
    box-shadow: 0 0 25px rgba(166, 124, 82, 0.6);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
