/* ========================================
   WARDOGZ KEYWORD ANALYZER - STYLES
   ======================================== */

:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8f9fa;
  --color-text: #1a1a1a;
  --color-text-muted: #6c757d;
  --color-primary: #000000;
  --color-primary-hover: #333333;
  --color-accent: #2563eb;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.logo span {
  color: var(--color-accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.quota-badge {
  background: var(--color-bg-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
}

.quota-badge strong {
  color: var(--color-accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

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

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

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

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text);
}

.form-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

/* Cards */
.card {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--color-bg-secondary);
  padding: 20px;
  border-radius: var(--radius-md);
  text-align: center;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
}

.metric-value.success { color: var(--color-success); }
.metric-value.warning { color: var(--color-warning); }
.metric-value.danger { color: var(--color-danger); }
.metric-value.accent { color: var(--color-accent); }

.metric-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--color-bg-secondary);
}

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

/* History Chart */
.history-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 10px 0;
  background: var(--color-bg-secondary);
  border-radius: 8px;
  padding: 15px 10px 5px 10px;
}

.bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  max-width: 30px;
  background: linear-gradient(to top, var(--color-primary), #888);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: all 0.3s ease;
}

.bar:hover {
  background: linear-gradient(to top, #000, #444);
  transform: scaleY(1.05);
}

.bar-label {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 6px;
  text-align: center;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-logo {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

/* Search Section */
.search-section {
  padding: 30px 0;
}

.search-box {
  display: flex;
  gap: 12px;
}

.search-box .form-input {
  flex: 1;
}

/* Results Section */
.results-section {
  padding-bottom: 40px;
}

.keyword-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.keyword-subtitle {
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

/* Sidebar */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 24px 0;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
}

.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.2s;
}

.history-item:hover {
  background: var(--color-bg-secondary);
}

.history-keyword {
  font-weight: 600;
  margin-bottom: 4px;
}

.history-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Alerts */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-error {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--color-text-muted);
  font-size: 13px;
  border-top: 1px solid var(--color-border);
  margin-top: 40px;
}

.footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

/* Admin Page */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.code-list {
  max-height: 500px;
  overflow-y: auto;
}

.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.code-value {
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  background: var(--color-bg-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.code-stats {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
