/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  /* Dynamic Slate/Sky Palette */
  --bg-body: #0f172a;
  /* Slate-900 */
  --bg-card: #1e293b;
  /* Slate-800 */
  --bg-input: #020617;
  /* Slate-950 */

  --text-main: #f8fafc;
  /* Slate-50 */
  --text-muted: #94a3b8;
  /* Slate-400 */

  --primary: #0ea5e9;
  /* Sky-500 */
  --primary-hover: #0284c7;
  /* Sky-600 */
  --secondary: #10b981;
  /* Emerald-500 */
  --danger: #ef4444;
  /* Red-500 */

  --border: #334155;
  /* Slate-700 */
  --border-focus: #38bdf8;
  /* Sky-400 */

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 15px rgba(14, 165, 233, 0.15);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   2. UTILITIES & LAYOUT
   ========================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.gap-2 {
  gap: 8px;
}

.gap-4 {
  gap: 16px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.w-full {
  width: 100%;
}

.text-center {
  text-align: center;
}

.hidden {
  display: none !important;
}

/* =========================================
   3. TYPOGRAPHY
   ========================================= */
h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* =========================================
   4. FORMS & INPUTS
   ========================================= */
input,
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* =========================================
   5. BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #0284c7);
  color: white;
  box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover {
  border-color: var(--text-main);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
}

.btn-ghost:hover {
  color: var(--primary);
  background: rgba(14, 165, 233, 0.1);
}

.btn-icon-only {
  padding: 6px;
  width: 32px;
  height: 32px;
}

/* =========================================
   6. COMPONENTS SPECIFIC
   ========================================= */

/* Header */
.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 16px 24px;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Badge */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  background: rgba(14, 165, 233, 0.15);
  color: var(--primary);
  border: 1px solid rgba(14, 165, 233, 0.3);
}

/* Output Area */
.output-area {
  background: #020617;
  /* Darker than card */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e2e8f0;
  overflow-x: auto;
  white-space: pre-wrap;
  min-height: 200px;
}

/* Progress Bar */
.progress-container {
  background: var(--bg-input);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(30, 41, 59, 0.5);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

/* Footer */
.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Login Specific */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 100%);
}

.login-card {
  width: 100%;
  max-width: 360px;
}

/* =========================================
   7. TOAST NOTIFICATIONS
   ========================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left-width: 4px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  color: var(--text-main);
  font-size: 0.9rem;
  min-width: 280px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-info {
  border-left-color: var(--primary);
}

.toast-success {
  border-left-color: var(--secondary);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0 0 12px;
}

.toast-close:hover {
  color: var(--text-main);
}