@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── CSS VARIABLES ──────────────────────────────────────────────────────── */
:root {
  --bg-primary:    #0A0A12;
  --bg-secondary:  #111118;
  --bg-card:       #16161F;
  --bg-card-hover: #1C1C28;
  --bg-input:      #1A1A25;
  --border:        rgba(255,255,255,0.07);
  --border-focus:  rgba(224,112,16,0.6);

  --orange:        #E07010;
  --orange-light:  #FF8C1A;
  --orange-glow:   rgba(224,112,16,0.15);
  --orange-bright: #FFA040;

  --text:          #F0F0F5;
  --text-muted:    #7A7A90;
  --text-dim:      #4A4A60;

  --success:       #22C55E;
  --error:         #EF4444;
  --warning:       #F59E0B;
  --info:          #3B82F6;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
  --shadow-orange: 0 0 20px rgba(224,112,16,0.25);

  --transition: 0.2s ease;
  --sidebar-w: 260px;
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--orange-bright); }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: 'Inter', sans-serif; }
input, select, textarea { font-family: 'Inter', sans-serif; }

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p { color: var(--text-muted); }

.text-orange { color: var(--orange-light); }
.text-muted  { color: var(--text-muted); }
.text-success{ color: var(--success); }
.text-error  { color: var(--error); }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
  transition: margin var(--transition);
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--orange);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-orange);
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.sidebar-logo .logo-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-company {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.company-badge {
  background: var(--orange-glow);
  border: 1px solid rgba(224,112,16,0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--orange-light);
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-item.active {
  background: var(--orange-glow);
  color: var(--orange-light);
  border: 1px solid rgba(224,112,16,0.15);
}

.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  display: flex; align-items: center; gap: 8px;
  transition: all var(--transition);
}
.logout-btn:hover {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.3);
  color: var(--error);
}

/* ─── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header-left h1 {
  font-size: 1.75rem;
  background: linear-gradient(135deg, #fff 0%, var(--orange-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.page-header-left p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
}

.card:hover { border-color: rgba(255,255,255,0.1); }
.card-header { margin-bottom: 20px; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ─── STATS GRID ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: rgba(224,112,16,0.2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 1.75rem;
  width: 48px; height: 48px;
  background: var(--orange-glow);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--orange);
  color: white;
  box-shadow: 0 2px 12px rgba(224,112,16,0.3);
}
.btn-primary:hover {
  background: var(--orange-light);
  box-shadow: 0 4px 20px rgba(224,112,16,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.15);
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--error);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
  background: rgba(239,68,68,0.25);
}

.btn-success {
  background: rgba(34,197,94,0.15);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.2);
}
.btn-success:hover {
  background: rgba(34,197,94,0.25);
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── FORMS ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  background: rgba(224,112,16,0.05);
  box-shadow: 0 0 0 3px rgba(224,112,16,0.1);
}

.form-control::placeholder { color: var(--text-dim); }
select.form-control option { background: var(--bg-secondary); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ─── TABLE ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }

tbody td {
  padding: 12px 16px;
  color: var(--text);
}

/* ─── BADGES / STATUS ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-draft    { background: rgba(107,114,128,0.15); color: #9CA3AF; border: 1px solid rgba(107,114,128,0.2); }
.badge-ready    { background: rgba(59,130,246,0.15);  color: #60A5FA; border: 1px solid rgba(59,130,246,0.2); }
.badge-generated{ background: rgba(34,197,94,0.15);  color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.badge-error    { background: rgba(239,68,68,0.15);  color: var(--error);   border: 1px solid rgba(239,68,68,0.2); }

/* ─── UPLOAD ZONE ────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-input);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--orange);
  background: var(--orange-glow);
}

.upload-zone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone-text { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-zone-sub  { font-size: 0.8rem; color: var(--text-muted); }

/* ─── STEP WIZARD ────────────────────────────────────────────────────────── */
.step-wizard {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.step-item:last-child { flex: 0; }

.step-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition);
}

.step-item.active .step-circle {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
  box-shadow: var(--shadow-orange);
}

.step-item.done .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.step-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.step-item.active .step-label { color: var(--orange-light); }
.step-item.done .step-label   { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  transition: all var(--transition);
}

.step-connector.done { background: var(--success); }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--transition);
}

.modal-overlay.show .modal { transform: scale(1); }

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

.modal-close {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(239,68,68,0.15);
  color: var(--error);
}

/* ─── ALERT / TOAST ──────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.info    { border-left: 3px solid var(--info); }

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-light));
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* ─── LOGIN PAGE ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(224,112,16,0.08) 0%, transparent 70%);
  top: -200px; right: -200px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(224,112,16,0.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.4s ease;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 16px;
  box-shadow: var(--shadow-orange);
}

.login-logo h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-logo p  { font-size: 0.875rem; color: var(--text-muted); }

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}

/* ─── COLUMN MAPPING ─────────────────────────────────────────────────────── */
.column-map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── PDF PREVIEW ────────────────────────────────────────────────────────── */
.cert-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3   { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p    { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 24px; }

/* ─── LOGO PREVIEW ───────────────────────────────────────────────────────── */
.logo-preview {
  width: 100%; max-height: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 8px;
  margin-top: 8px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .step-label { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ─── ANIMATIONS ─────────────────────────────────────────────────────────── */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin  { to { transform: rotate(360deg); } }

.loading-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card-hover) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
