:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252540;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --error: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-left {
  flex: 1;
  text-align: left;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#username-display {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.admin-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.admin-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.company-switcher {
  display: flex;
  align-items: center;
  margin-right: 1rem;
}

.company-select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.company-select:hover {
  border-color: var(--accent);
}

.company-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.company-badge {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.company-badge.lagoona {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}

.company-badge.dina {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.controls .full-width {
  grid-column: 1 / -1;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.select-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

select {
  appearance: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

select:hover {
  border-color: var(--accent);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Upload Zone */
.upload-zone {
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.upload-zone.dragover {
  transform: scale(1.02);
  box-shadow: 0 0 30px var(--accent-glow);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  filter: grayscale(0.3);
}

.upload-zone p {
  color: var(--text-secondary);
}

.browse-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* File List */
.files-section,
.outputs-section {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.files-section h2,
.outputs-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.file-list,
.output-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.output-list::-webkit-scrollbar {
  width: 8px;
}

.output-list::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.output-list::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.output-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.file-item,
.output-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.file-item:hover,
.output-item:hover {
  background: rgba(99, 102, 241, 0.1);
}

.file-info,
.output-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-icon {
  font-size: 1.25rem;
}

.file-name,
.output-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.file-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge.processed {
  background: var(--success-bg);
  color: var(--success);
}

/* Generate Button */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--accent-glow);
}

.generate-btn:active {
  transform: translateY(0);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.generate-btn .btn-icon {
  font-size: 1.25rem;
}

/* Status */
.status {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  text-align: center;
}

.status.hidden {
  display: none;
}

.status.loading {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.status.success {
  background: var(--success-bg);
  color: var(--success);
}

.status.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

/* Download Button */
.download-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.download-btn:hover {
  background: var(--accent-hover);
}

/* Unmark Button */
.unmark-btn {
  padding: 0.25rem 0.6rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.unmark-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border-color: var(--error);
}

/* Delete Button */
.delete-btn {
  padding: 0.25rem 0.6rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border-color: var(--error);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-item,
.output-item {
  animation: fadeIn 0.3s ease;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

.status.loading {
  animation: pulse 1.5s infinite;
}

/* Files Table */
.files-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow: hidden;
}

.files-table thead {
  background: var(--bg-tertiary);
}

.files-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.files-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}

.files-table tbody tr:last-child td {
  border-bottom: none;
}

.files-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.files-table input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.generated-file-cell {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.generated-file {
  color: var(--success);
  font-weight: 500;
}

/* Secondary Button */
.secondary-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.secondary-btn:disabled {
  background: var(--bg-tertiary);
  border-color: var(--border);
  opacity: 0.5;
}

/* Responsive */
@media (max-width: 480px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 1.5rem 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .files-table {
    font-size: 0.875rem;
  }

  .files-table th,
  .files-table td {
    padding: 0.5rem;
  }
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Download Links */
.download-link {
  color: var(--accent);
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.download-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.download-link:active {
  transform: scale(0.98);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border-left: 4px solid var(--accent);
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-icon {
  font-size: 20px;
  font-weight: bold;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-left-color: var(--error);
}

.toast-error .toast-icon {
  color: var(--error);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info {
  border-left-color: var(--accent);
}

.toast-info .toast-icon {
  color: var(--accent);
}

.toast-loading {
  border-left-color: var(--accent);
}

.toast-loading .toast-icon {
  color: var(--accent);
  animation: spin 1s linear infinite;
}

/* Filter Controls */
.filter-controls {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 150px;
}

.filter-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-group select,
.filter-group input {
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.clear-filters-btn {
  padding: 0.75rem 1.25rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  align-self: flex-end;
}

.clear-filters-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.file-list {
  margin-top: 1rem;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.file-list::-webkit-scrollbar {
  width: 8px;
}

.file-list::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.file-list::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.3s ease;
  border-radius: 2px;
}

.progress-bar.indeterminate {
  width: 30%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(400%);
  }
}

/* Table Row Animations */
.files-table tbody tr {
  transition: all 0.3s ease;
}

.files-table tbody tr.fade-in {
  animation: fadeInUp 0.3s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.files-table tbody tr:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Pagination Controls */
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.pagination-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.pagination-buttons {
  display: flex;
  gap: 0.5rem;
}

.pagination-buttons button {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.pagination-buttons button:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pagination-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.items-per-page {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.items-per-page select {
  padding: 0.4rem 0.6rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}