/* ==========================================================================
   QR Code Generator - Stylesheet (taoqr.io.vn Clone)
   ========================================================================== */

:root {
  /* Colors - Light Theme */
  --bg-gradient: linear-gradient(135deg, #e3f2fd 0%, #ffffff 50%, #f3e5f5 100%);
  --footer-bg: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 50%, #f5f5f5 100%);
  --paper-bg: #ffffff;
  --paper-shadow: 0px 3px 3px -2px rgba(0,0,0,0.2), 0px 3px 4px 0px rgba(0,0,0,0.14), 0px 1px 8px 0px rgba(0,0,0,0.12);
  --paper-shadow-hover: 0px 6px 10px -2px rgba(0,0,0,0.2), 0px 6px 8px 0px rgba(0,0,0,0.14), 0px 2px 14px 0px rgba(0,0,0,0.12);
  
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.6);
  --text-disabled: rgba(0, 0, 0, 0.38);
  --divider: rgba(0, 0, 0, 0.12);
  
  --primary: #1976d2;
  --primary-hover: #1565c0;
  --primary-light: rgba(25, 118, 210, 0.08);
  --primary-contrast: #ffffff;
  
  --secondary: #9c27b0;
  --success: #2e7d32;
  --success-light: rgba(46, 125, 50, 0.1);
  --error: #d32f2f;
  
  --input-border: rgba(0, 0, 0, 0.23);
  --input-border-hover: rgba(0, 0, 0, 0.87);
  --input-bg: transparent;
  
  --switch-track: rgba(0, 0, 0, 0.38);
  --switch-thumb: #ffffff;
}

[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #121212 0%, #1e1e1e 50%, #121212 100%);
  --footer-bg: linear-gradient(135deg, #181818 0%, #222222 50%, #181818 100%);
  --paper-bg: #1e1e1e;
  --paper-shadow: 0px 3px 5px -1px rgba(0,0,0,0.5), 0px 5px 8px 0px rgba(0,0,0,0.4), 0px 1px 14px 0px rgba(0,0,0,0.3);
  --paper-shadow-hover: 0px 6px 12px -1px rgba(0,0,0,0.6), 0px 8px 14px 0px rgba(0,0,0,0.5), 0px 2px 18px 0px rgba(0,0,0,0.4);
  
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-disabled: rgba(255, 255, 255, 0.38);
  --divider: rgba(255, 255, 255, 0.12);
  
  --primary: #90caf9;
  --primary-hover: #42a5f5;
  --primary-light: rgba(144, 202, 249, 0.12);
  --primary-contrast: #121212;
  
  --input-border: rgba(255, 255, 255, 0.23);
  --input-border-hover: rgba(255, 255, 255, 0.87);
  --input-bg: rgba(255, 255, 255, 0.05);
  
  --switch-track: rgba(255, 255, 255, 0.38);
  --switch-thumb: #90caf9;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

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

body {
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-gradient);
  min-height: 100vh;
  transition: background 0.5s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #1976d2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.main-container {
  max-width: 1152px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
  flex: 1;
  padding-bottom: 40px;
}

.app-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 900px) {
  .app-grid {
    flex-direction: row;
    align-items: flex-start;
  }
}

/* ==========================================================================
   Cards & Surfaces (MuiPaper)
   ========================================================================== */

.paper-card {
  background-color: var(--paper-bg);
  color: var(--text-primary);
  border-radius: 8px;
  box-shadow: var(--paper-shadow);
  padding: 24px;
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.paper-card.form-card {
  flex: 1.2;
}

.paper-card.preview-card {
  flex: 0.9;
  min-width: 320px;
}

/* ==========================================================================
   Theme Switcher Button
   ========================================================================== */

.theme-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.theme-toggle-btn:hover {
  transform: scale(1.1);
  background-color: var(--primary);
  color: var(--paper-bg);
  border-color: var(--paper-bg);
}

.theme-toggle-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Tooltip */
.tooltip-container {
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 125%;
  right: 0;
  background-color: rgba(97, 97, 97, 0.92);
  color: #fff;
  text-align: center;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   QR Type Selector Grid
   ========================================================================== */

.section-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: block;
}

.qr-types-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

@media (min-width: 600px) {
  .qr-types-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.qr-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
  border: 1px solid rgba(25, 118, 210, 0.4);
  color: var(--primary);
  outline: none;
  min-height: 58px;
}

.qr-type-btn .type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.qr-type-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.qr-type-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
}

.qr-type-btn.active {
  background-color: #1976d2;
  color: #ffffff;
  border-color: #1976d2;
  box-shadow: 0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12);
}

/* ==========================================================================
   Form Fields (Material UI Style)
   ========================================================================== */

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.input-container {
  position: relative;
  width: 100%;
}

.input-with-icon {
  display: flex;
  align-items: center;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 0 14px;
  background-color: var(--input-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.input-with-icon:hover {
  border-color: var(--input-border-hover);
}

.input-with-icon:focus-within {
  border-color: #1976d2;
  box-shadow: 0 0 0 1px #1976d2;
}

.input-with-icon.has-error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 1px var(--error) !important;
}

.input-adornment {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  margin-right: 10px;
  flex-shrink: 0;
}

.input-adornment svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.form-control {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 0;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-primary);
}

.form-control::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

textarea.form-control {
  resize: vertical;
  padding: 12px 0;
  min-height: 90px;
}

.select-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 36px;
}

.input-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-helper {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.field-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
  display: none;
}

.field-error.visible {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

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

/* ==========================================================================
   Appearance Customization (Màu sắc)
   ========================================================================== */

.custom-appearance-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 600px) {
  .custom-appearance-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.custom-card-inner {
  background-color: var(--paper-bg);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.custom-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.custom-card-label {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
}

/* Material Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--switch-track);
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input:checked + .slider {
  background-color: #1976d2;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.color-picker-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--divider);
}

.color-input {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--divider);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.color-value {
  font-size: 0.875rem;
  font-family: monospace;
  color: var(--text-secondary);
}

/* ==========================================================================
   Image / Logo Upload Dropzone
   ========================================================================== */

.dropzone-container {
  margin-bottom: 24px;
}

.dropzone {
  border: 2px dashed var(--divider);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background-color: var(--paper-bg);
  transition: all 0.3s ease;
  outline: none;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: #1976d2;
  background-color: rgba(25, 118, 210, 0.04);
}

.dropzone.has-file {
  border-color: var(--success);
  background-color: var(--success-light);
}

.dropzone-icon {
  font-size: 48px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.dropzone-icon svg {
  width: 48px;
  height: 48px;
  fill: currentColor;
}

.dropzone-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
}

/* File Selected State */
.file-info-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.file-preview-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.preview-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--divider);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.file-meta {
  text-align: left;
}

.file-status {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 2px;
}

.file-name {
  font-size: 0.8125rem;
  color: var(--text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.file-action-btns {
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 4px 12px;
  font-size: 0.8125rem;
  border-radius: 4px;
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-small:hover {
  background-color: rgba(0,0,0,0.05);
}

.btn-small.btn-danger {
  color: var(--error);
  border-color: rgba(211, 47, 47, 0.4);
}

.btn-small.btn-danger:hover {
  background-color: rgba(211, 47, 47, 0.08);
  border-color: var(--error);
}

/* ==========================================================================
   Submit & Action Buttons
   ========================================================================== */

.btn-primary-gradient {
  width: 100%;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #ffffff;
  background: linear-gradient(45deg, #2196F3 30%, #9C27B0 90%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12);
  transition: all 0.3s ease;
}

.btn-primary-gradient:hover {
  background: linear-gradient(45deg, #1976D2 30%, #7B1FA2 90%);
  box-shadow: 0px 5px 8px -2px rgba(0,0,0,0.25), 0px 8px 14px 1px rgba(0,0,0,0.18), 0px 3px 20px 2px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}

.btn-primary-gradient:active {
  transform: translateY(1px);
}

.btn-primary-gradient:disabled {
  background: #bdbdbd;
  color: #757575;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-download-gradient {
  width: 100%;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(45deg, #4CAF50 30%, #2196F3 90%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14);
  transition: all 0.3s ease;
  margin-bottom: 20px;
}

.btn-download-gradient:hover {
  background: linear-gradient(45deg, #388E3C 30%, #1976D2 90%);
  transform: translateY(-1px);
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Preview Card (Right Column)
   ========================================================================== */

.preview-empty-state {
  text-align: center;
  padding: 56px 16px;
}

.empty-avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px auto;
  opacity: 0.8;
}

[data-theme="dark"] .empty-avatar {
  background-color: rgba(255, 255, 255, 0.08);
}

.empty-avatar svg {
  width: 96px;
  height: 96px;
  fill: currentColor;
}

.preview-empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.preview-empty-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Generated State */
.preview-result-state {
  display: none;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.qr-image-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.qr-image-card {
  padding: 16px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0px 3px 6px rgba(0,0,0,0.15);
  display: inline-block;
  line-height: 0;
}

.qr-image-card img {
  max-width: 280px;
  max-height: 280px;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.qr-info-card {
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 16px;
}

.qr-info-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.qr-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 0.875rem;
}

.qr-info-row:last-child {
  border-bottom: none;
}

.qr-info-label {
  color: var(--text-secondary);
}

.qr-info-value {
  color: var(--text-primary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-badge {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--divider);
  display: inline-block;
}

.chip-tag {
  background-color: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer-wrapper {
  background: var(--footer-bg);
  padding: 48px 16px 24px 16px;
  margin-top: auto;
  border-top: 1px solid var(--divider);
  transition: background 0.5s ease;
}

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

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

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

@media (min-width: 992px) {
  .footer-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.footer-col-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.footer-col-title.brand {
  color: #1976d2;
}

.footer-desc {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.social-links {
  display: flex;
  gap: 8px;
}

.social-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.social-btn:hover {
  background-color: rgba(0, 0, 0, 0.06);
  color: #1976d2;
}

.footer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-list-item {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-list-item a {
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.footer-list-item a:hover {
  color: #1976d2;
  text-decoration: none;
}

.footer-divider {
  border: none;
  height: 1px;
  background-color: var(--divider);
  margin-bottom: 24px;
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

@media (min-width: 768px) {
  .footer-bottom {
    flex-direction: row;
  }
}

.author-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid var(--divider);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 480px;
  padding: 12px 18px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

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

.toast.toast-success {
  background-color: #2e7d32;
}

.toast.toast-error {
  background-color: #d32f2f;
}

.toast svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}
