/* ============================================================
   Populi Tools — Modern Stylesheet
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #e0e7ff;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-info: #0284c7;
  --color-info-light: #e0f2fe;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-header-bg: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Header ---- */
.app-header {
  background: var(--color-header-bg);
  color: #fff;
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.app-header p {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

/* ---- Main Container ---- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ---- Upload Card ---- */
.upload-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--color-border);
}

.upload-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.upload-card p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ---- File Input ---- */
.file-input-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.file-input-label:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.file-input-label svg {
  width: 20px;
  height: 20px;
}

.file-input-label input[type="file"] {
  display: none;
}

.file-name {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
  box-shadow: 0 1px 2px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
  background: #15803d;
  transform: translateY(-1px);
}

.btn-success:active {
  transform: translateY(0);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary-light);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

/* ---- Progress Bar ---- */
.progress-bar {
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.progress-bar span {
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
}

.progress-bar .progress-text {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Table ---- */
.table-wrapper {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table thead th {
  background: linear-gradient(to bottom, #f1f5f9, #e2e8f0);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: #f1f5f9;
}

.data-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.data-table tbody tr:nth-child(even):hover {
  background: #f1f5f9;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
}

.data-table td:first-child {
  font-weight: 500;
}

/* ---- Result Badges ---- */
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

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

.result-badge.error {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.result-badge.warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.result-badge.info {
  background: var(--color-info-light);
  color: var(--color-info);
}

.result-badge.neutral {
  background: #f1f5f9;
  color: var(--color-text-secondary);
}

/* ---- Status Icons ---- */
.status-icon {
  font-size: 0.875rem;
  display: inline-block;
  width: 1.25rem;
  text-align: center;
}

/* ---- Cell Group ---- */
.cell-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9375rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .upload-card {
    padding: 1.25rem;
  }

  .app-header {
    padding: 1rem 1.25rem;
  }

  .app-header h1 {
    font-size: 1.25rem;
  }

  .data-table {
    font-size: 0.8125rem;
  }

  .data-table td,
  .data-table th {
    padding: 0.5rem 0.625rem;
  }

  .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .file-input-wrapper {
    flex-direction: column;
    align-items: flex-start;
  }

  .cell-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

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

.data-table tbody tr {
  animation: fadeIn 0.3s ease both;
}

/* ---- Scrollbar ---- */
.table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
