/* ========================================
   SERP Dashboard - Main Stylesheet
   Google Analytics inspired design
   ======================================== */

:root {
  /* Light mode colors */
  --color-bg: #ffffff;
  --color-bg-alt: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #dadce0;
  --color-text: #202124;
  --color-text-secondary: #5f6368;
  --color-text-tertiary: #80868b;
  --color-primary: #1a73e8;
  --color-primary-hover: #1557b0;
  --color-success: #1e8e3e;
  --color-warning: #f9ab00;
  --color-error: #d93025;
  --color-link: #1a73e8;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
  --shadow-md: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);

  /* Layout */
  --nav-height: 56px;
  --sidebar-width: 240px;
  --content-max-width: 1200px;

  /* Typography */
  --font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'Courier New', monospace;
}

[data-theme="dark"] {
  --color-bg: #202124;
  --color-bg-alt: #292a2d;
  --color-surface: #292a2d;
  --color-border: #5f6368;
  --color-text: #e8eaed;
  --color-text-secondary: #9aa0a6;
  --color-text-tertiary: #80868b;
  --color-primary: #8ab4f8;
  --color-primary-hover: #aecbfa;
  --color-success: #81c995;
  --color-warning: #fdd663;
  --color-error: #f28b82;
  --color-link: #8ab4f8;
}

/* ========================================
   Base Styles
   ======================================== */

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-base);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

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

a:hover {
  text-decoration: underline;
}

/* ========================================
   Layout
   ======================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
}

.nav-logo {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text);
  margin-right: 40px;
}

.nav-items {
  display: flex;
  gap: 32px;
  flex: 1;
}

.nav-item {
  color: var(--color-text-secondary);
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.nav-item:hover {
  color: var(--color-text);
  text-decoration: none;
}

.nav-item.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

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

.theme-toggle {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  font-size: 18px;
}

.theme-toggle:hover {
  background: var(--color-bg-alt);
}

.user-menu {
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.main {
  margin-top: var(--nav-height);
  padding: 24px;
  max-width: var(--content-max-width);
  margin-left: auto;
  margin-right: auto;
}

/* ========================================
   Cards & Surfaces
   ======================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--color-text);
}

.table-container {
  overflow-x: auto;
  margin: 0 -24px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  border-bottom: 1px solid var(--color-border);
}

th {
  text-align: left;
  font-weight: 500;
  padding: 12px 24px;
  color: var(--color-text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
}

tr:hover {
  background: var(--color-bg-alt);
}

/* ========================================
   Forms & Inputs
   ======================================== */

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-base);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-base);
  gap: 8px;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-error {
  background: var(--color-error);
  color: white;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 13px;
}

/* ========================================
   Badges & Status
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: rgba(30, 142, 62, 0.1);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(249, 171, 0, 0.1);
  color: var(--color-warning);
}

.badge-error {
  background: rgba(217, 48, 37, 0.1);
  color: var(--color-error);
}

.badge-info {
  background: rgba(26, 115, 232, 0.1);
  color: var(--color-primary);
}

/* ========================================
   Stats & Metrics
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
}

.stat-label {
  color: var(--color-text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 500;
  color: var(--color-text);
}

.stat-change {
  font-size: 12px;
  margin-top: 4px;
}

.stat-change.positive {
  color: var(--color-success);
}

.stat-change.negative {
  color: var(--color-error);
}

/* ========================================
   Alerts & Messages
   ======================================== */

.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
  border-left: 4px solid;
}

.alert-success {
  background: rgba(30, 142, 62, 0.1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.alert-error {
  background: rgba(217, 48, 37, 0.1);
  border-color: var(--color-error);
  color: var(--color-error);
}

.alert-warning {
  background: rgba(249, 171, 0, 0.1);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.alert-info {
  background: rgba(26, 115, 232, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ========================================
   Utilities
   ======================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-secondary); }
.text-small { font-size: 13px; }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 12px; }
.mb-md { margin-bottom: 20px; }
.mb-lg { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 20px; }
.mt-lg { margin-top: 32px; }

.hidden { display: none; }

/* ========================================
   Page Header
   ======================================== */

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 24px;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 8px;
}

.page-subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ========================================
   Loading States
   ======================================== */

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
/* ========================================
   Pagination
   ======================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--color-border);
  margin-top: 20px;
}

.pagination-info {
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ========================================
   Filter Form
   ======================================== */

.filter-form {
  padding: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}

/* ========================================
   Domain Link
   ======================================== */

.domain-link {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 500;
}

.domain-link:hover {
  text-decoration: underline;
}

/* ========================================
   Stat Value Sizes
   ======================================== */

.stat-value-sm {
  font-size: 18px;
}

/* ========================================
   Page Actions
   ======================================== */

.page-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
