/* 
  SEO Analytics Premium Dashboard CSS
  Modern, vibrant, and clean design system.
*/
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Color Palette */
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  
  --secondary-color: #0ea5e9;
  
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --purple-color: #8b5cf6;
  
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --border-color: #e2e8f0;
  
  /* Layout & Spacing */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* ── Layout ── */
.dashboard-wrapper {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 24px 40px;
  box-sizing: border-box;
}

/* ── Navigation (Top Bar) ── */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 32px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-nav h1 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color), var(--purple-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-item {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--surface-color);
  border-color: var(--border-color);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
  border-color: rgba(79, 70, 229, 0.2);
}

.nav-item.logout {
  color: var(--danger-color);
}
.nav-item.logout:hover {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.2);
}

/* ── UI Components ── */
.card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
  background: var(--surface-color);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* ── Form Inputs & Filters ── */
  .filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    background: var(--surface-color);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
  }

  .filter-bar .form-group {
    flex: 1 1 0;
    min-width: 0;
  }

  .filter-bar .form-control,
  .filter-bar select {
    width: 100%;
    padding: 7px 8px;
    font-size: 0.8rem;
  }

.filter-bar > div:last-child {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.filter-bar > div:last-child .btn {
    padding: 7px 12px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.form-control, select, input[type="text"], input[type="password"] {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--surface-color);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: var(--transition);
  outline: none;
}

.form-control:focus, select:focus, input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ── Modern Tables ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--surface-color);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.table-modern {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.table-modern th {
  background: #f8fafc;
  padding: 12px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
  white-space: nowrap;
}

.table-modern th.sortable {
  cursor: pointer;
  transition: background 0.2s;
}

.table-modern th.sortable:hover {
  background: #f1f5f9;
}

.table-modern td {
  padding: 10px 12px;
  font-size: 0.875rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table-modern.table-compact {
  white-space: normal;
}

.table-modern.table-compact th {
  padding: 6px 6px;
  font-size: 0.7rem;
  white-space: normal;
}

.table-modern.table-compact td {
  padding: 4px 6px;
  font-size: 0.75rem;
  white-space: normal;
  word-break: break-word;
}

.table-modern tbody tr {
  transition: background 0.15s;
}

.table-modern tbody tr:hover {
  background: var(--primary-light);
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

/* ── Badges & Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.excel-cell {
    background: #fff;
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    font-size: 0.85rem;
    text-align: right;
    color: var(--text-main);
    transition: var(--transition);
}

.excel-cell:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.editable-remark {
  padding: 8px;
  min-height: 20px;
  border-radius: var(--radius-sm);
  border: 1px dashed transparent;
  transition: var(--transition);
  outline: none;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-x: hidden;
  overflow-y: auto;
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.editable-remark:focus, .editable-remark:hover {
  border-color: #cbd5e1;
  background: #fff;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

/* Legend Box (Marked Report specific) */
.legend-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.color-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

/* Alerts */
.alert {
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Loader */
#loader {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-main);
  color: #fff;
  padding: 12px 24px;
  border-radius: 99px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  display: none;
  animation: fadeUp 0.3s ease;
}

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

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 16px; 
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Table Sorting Styles */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.sort-link:hover {
    color: var(--primary-color);
}

.sort-icon {
    font-size: 0.7em;
    margin-left: 2px;
    color: var(--primary-color);
}

.sort-active {
    font-weight: 800;
    color: var(--primary-color);
}
