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

:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --success-color: #10b981;
  --error-color: #ef4444;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding: 2rem 1rem;
}

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

header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

header p {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

.card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.card-description {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

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

label {
  display: block;
  margin-bottom: 0.5rem;
}

.label-text {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

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

input[type="file"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card-bg);
}

input[type="file"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="file"] {
  cursor: pointer;
}

.file-info {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.file-info.success {
  color: var(--success-color);
  font-weight: 500;
}

.btn-primary {
  width: 100%;
  padding: 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  position: relative;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  padding: 1rem;
  background: var(--card-bg);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  position: relative;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.05);
}

.btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-secondary:disabled {
  background: var(--bg-color);
  color: var(--text-secondary);
  border-color: var(--border-color);
  cursor: not-allowed;
}

.btn-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.result {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid var(--border-color);
}

.result.success {
  background: #f0fdf4;
  border-color: var(--success-color);
  color: #166534;
}

.result.error {
  background: #fef2f2;
  border-color: var(--error-color);
  color: #991b1b;
}

.result h3 {
  margin-bottom: 0.5rem;
  font-size: 1.125rem;
}

.result p {
  margin-bottom: 0.5rem;
}

/* Batch Progress Styles */
.batch-progress {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.progress-bar-container {
  width: 100%;
  height: 24px;
  background: #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
  border-radius: 12px;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
}

.progress-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
}

.result code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  display: inline-block;
  margin-top: 0.5rem;
  word-break: break-all;
}

.result .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.result .stat-box {
  background: rgba(0, 0, 0, 0.03);
  padding: 0.75rem;
  border-radius: 6px;
  text-align: center;
}

.result .stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  display: block;
}

.result .stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.info-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.info-section h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.info-section ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.info-section li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.command-box {
  background: var(--bg-color);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.command-box strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.command-box code {
  display: block;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--text-secondary);
  word-break: break-all;
}

/* Authentication Styles */
.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
}

.auth-required {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-color);
}

/* Header with User Menu */
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
}

/* File Management Styles */
.file-upload-section {
  margin-bottom: 1.5rem;
}

.stored-files-list {
  margin-top: 1.5rem;
}

.loading-files,
.loading-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  color: var(--text-secondary);
  text-align: center;
  justify-content: center;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
  background: var(--bg-color);
}

.file-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.file-item.selected {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.file-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-item-name {
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.folder-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary-color);
}

.file-item-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.file-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-select,
.btn-delete,
.btn-download {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-select {
  background: var(--primary-color);
  color: white;
}

.btn-select:hover {
  background: var(--primary-hover);
}

.btn-select:disabled {
  background: var(--success-color);
  cursor: not-allowed;
}

.btn-delete {
  background: var(--error-color);
  color: white;
}

.btn-delete:hover {
  background: #dc2626;
}

.btn-download {
  background: var(--text-secondary);
  color: white;
}

.btn-download:hover {
  background: #475569;
}

.selected-file-display {
  padding: 1rem;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  background: var(--bg-color);
}

.selected-file-display.has-selection {
  border-color: var(--success-color);
  border-style: solid;
  background: rgba(16, 185, 129, 0.05);
}

.selected-file-display .no-selection {
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}

.selected-file-display .file-selected {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  margin: 0;
}

.selected-file-display .file-selected strong {
  color: var(--success-color);
}

.no-files-message {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.header-content > div:first-child {
  text-align: left;
}

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

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

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

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.modal-body ul {
  margin-left: 1.5rem;
  color: var(--text-secondary);
}

.modal-body ul li {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.modal-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.modal-footer button {
  min-width: 100px;
}

@media (max-width: 640px) {
  body {
    padding: 1rem 0.5rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .card {
    padding: 1.5rem;
  }

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

  .modal-content {
    width: 95%;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer button {
    width: 100%;
  }
}
