/* ============================================================
   WebCrawler Intelligence - Main Stylesheet
   ============================================================ */

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

:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a9e;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --orange: #ea580c;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; transition: all .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); border-color: #94a3b8; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; background: white; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.checkbox-group input[type=checkbox] { width: auto; }

/* ---- Alerts ---- */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; color: white; letter-spacing: .5px;
}
.badge-green { background: var(--success); color: white; }
.badge-gray { background: #94a3b8; color: white; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }

/* ============================================================
   Auth Pages
   ============================================================ */
.auth-page { background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-container { width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; justify-content: center; }
.auth-logo h1 { color: white; font-size: 20px; font-weight: 700; }
.auth-card { background: white; padding: 32px; border-radius: 12px; box-shadow: var(--shadow-md); }
.auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 24px; color: var(--text); }
.auth-link { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }

/* ============================================================
   App Layout
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--primary); color: white;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-title { font-size: 14px; font-weight: 600; color: white; }
.nav-links { list-style: none; flex: 1; padding: 12px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px; color: rgba(255,255,255,.75);
  font-size: 14px; font-weight: 500; text-decoration: none;
  transition: all .15s; margin-bottom: 2px;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.15); color: white; text-decoration: none; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.btn-logout { width: 100%; background: transparent; color: rgba(255,255,255,.7); border: 1px solid rgba(255,255,255,.2); padding: 8px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all .15s; }
.btn-logout:hover { background: rgba(255,255,255,.1); color: white; }

.main-content { margin-left: var(--sidebar-w); flex: 1; }
.page-content { padding: 28px 32px; max-width: 1200px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 26px; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ---- Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; text-align: center; box-shadow: var(--shadow);
}
.stat-card.critical { border-top: 3px solid var(--danger); }
.stat-card.high { border-top: 3px solid var(--orange); }
.stat-card.medium { border-top: 3px solid var(--warning); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat-mini { font-size: 13px; color: var(--text-muted); }

/* ---- Dashboard Grid ---- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ---- Findings ---- */
.findings-list { padding: 0 20px; }
.finding-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.finding-item:last-child { border-bottom: none; }
.finding-body { flex: 1; min-width: 0; }
.finding-title { font-size: 14px; font-weight: 600; color: var(--text); display: block; }
.finding-title:hover { color: var(--accent); }
.finding-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.finding-summary { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

.finding-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.finding-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.finding-type { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }
.finding-date { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.finding-site { font-size: 12px; font-weight: 600; color: var(--primary); }
.finding-card-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.finding-card-title a { color: var(--text); }
.finding-card-title a:hover { color: var(--accent); }
.finding-summary-box {
  background: #f0f9ff; border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 0 4px 4px 0; font-size: 13px;
  color: #0c4a6e; margin-bottom: 10px; line-height: 1.6;
}
.finding-diff { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; font-style: italic; }
.finding-actions { display: flex; gap: 8px; }
.empty { color: var(--text-muted); font-size: 14px; padding: 20px 0; text-align: center; }

/* ---- Filter bar ---- */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar .select { width: auto; }
.count-badge { font-size: 13px; color: var(--text-muted); margin-left: auto; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 20px 0; }
#page-info { font-size: 14px; color: var(--text-muted); }

/* ---- Scan items ---- */
.scans-list { padding: 0 20px; }
.scan-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.scan-item:last-child { border-bottom: none; }
.scan-status { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.scan-status.completed { background: #dcfce7; color: #166534; }
.scan-status.running { background: #dbeafe; color: #1e40af; }
.scan-status.failed { background: #fee2e2; color: #991b1b; }
.scan-status.pending { background: #fef9c3; color: #854d0e; }
.scan-body { display: flex; gap: 12px; flex-wrap: wrap; }
.scan-site { font-weight: 600; }
.scan-meta { color: var(--text-muted); }

.scan-row { display: flex; gap: 16px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); align-items: center; }
.scan-history h4 { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 12px 0 6px; }

/* ---- Settings ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-form { padding: 16px 20px; }
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.save-msg { font-size: 13px; color: var(--success); font-weight: 500; }

/* ---- Sites ---- */
.sites-detail { }
.site-detail-card .card-header { display: block; }
.site-detail-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 20px; }
.site-detail-header h2 { font-size: 18px; font-weight: 700; }
.site-detail-stats { display: flex; gap: 16px; font-size: 13px; }
.site-url { font-size: 13px; color: var(--text-muted); display: block; margin-top: 2px; }

.site-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.site-item:last-child { border-bottom: none; }
.site-info { display: flex; flex-direction: column; gap: 2px; }
.site-name { font-size: 14px; font-weight: 600; }
.site-url { font-size: 12px; color: var(--text-muted); }
.site-meta { font-size: 12px; color: var(--text-muted); }
.site-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Subscriptions ---- */
.sub-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.sub-item:last-child { border-bottom: none; }
.sub-info { display: flex; flex-direction: column; gap: 3px; }
.sub-site { font-size: 14px; font-weight: 600; }
.sub-meta { font-size: 12px; color: var(--text-muted); }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); }
.modal-content { background: white; border-radius: 12px; padding: 28px; max-width: 480px; width: 100%; position: relative; z-index: 1; box-shadow: var(--shadow-md); }
.modal-content h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ============================================================
   Landing Page
   ============================================================ */
.landing-page { background: white; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.landing-header { background: white; border-bottom: 1px solid var(--border); padding: 16px 0; position: sticky; top: 0; z-index: 50; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--primary); }
.landing-nav-links { display: flex; gap: 10px; align-items: center; }

.hero { background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%); color: white; padding: 80px 0; text-align: center; }
.hero-title { font-size: 44px; font-weight: 800; line-height: 1.15; margin-bottom: 20px; }
.hero-subtitle { font-size: 18px; color: rgba(255,255,255,.8); max-width: 600px; margin: 0 auto 32px; line-height: 1.6; }
.hero-actions { display: flex; gap: 14px; justify-content: center; }
.btn-ghost.btn-lg { color: white; border-color: rgba(255,255,255,.4); }
.btn-ghost.btn-lg:hover { background: rgba(255,255,255,.1); }

.features { padding: 80px 0; background: var(--bg); }
.section-title { font-size: 32px; font-weight: 700; text-align: center; margin-bottom: 48px; color: var(--text); }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
@media (max-width: 768px) { .features-grid { grid-template-columns: 1fr 1fr; } .hero-title { font-size: 30px; } }
@media (max-width: 480px) { .features-grid { grid-template-columns: 1fr; } }
.feature-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.feature-icon { font-size: 32px; margin-bottom: 12px; }
.feature-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.feature-card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

.landing-footer { background: var(--primary); color: rgba(255,255,255,.6); padding: 24px 0; text-align: center; font-size: 13px; }

/* ---- Misc ---- */
.loading { color: var(--text-muted); font-size: 14px; padding: 20px; text-align: center; }
