/* user_dashboard.css — PhishGuard User Dashboard */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --secondary-color: #10b981;
  --navy: #0f2d5a;
  --navy-mid: #1a4280;
  --text-dark: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --surface: #f8fafc;
  --red: #ef4444;
  --amber: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--surface); color: var(--text-dark); }

.dash-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.dash-sidebar {
  width: 240px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  box-shadow: 2px 0 8px rgba(0,0,0,.04); z-index: 100;
}
.dash-sidebar-brand {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--navy);
}
.dash-sidebar-brand i { font-size: 1.25rem; color: var(--primary-color); }
.dash-sidebar-brand span { font-size: 1.1rem; font-weight: 700; }
.dash-sidebar-brand em { font-style: normal; color: var(--primary-color); }

.dash-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.dash-nav-item {
  display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem;
  color: var(--text-light); text-decoration: none; font-size: .9rem; font-weight: 500;
  border-left: 3px solid transparent; transition: all .15s; cursor: pointer;
}
.dash-nav-item:hover { background: #f1f5f9; color: var(--text-dark); }
.dash-nav-item.active { color: var(--primary-color); background: rgba(37,99,235,.06); border-left-color: var(--primary-color); font-weight: 600; }
.dash-nav-item i { width: 20px; text-align: center; font-size: .85rem; }

.dash-sidebar-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
}
.dash-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary-color);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.dash-user-info { flex: 1; min-width: 0; }
.dash-user-name { font-size: .85rem; font-weight: 600; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-user-plan { font-size: .7rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .5px; }

/* Main content */
.dash-main { flex: 1; margin-left: 240px; padding: 2rem; }
.dash-header { margin-bottom: 2rem; }
.dash-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--navy); margin-bottom: .25rem; }
.dash-header p { color: var(--text-light); font-size: .9rem; }

/* Tab content */
.dash-tab { display: none; }
.dash-tab.active { display: block; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 1.5rem; border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.06); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: .75rem; font-size: 1rem; }
.stat-icon.blue { background: rgba(37,99,235,.1); color: var(--primary-color); }
.stat-icon.red { background: rgba(239,68,68,.1); color: var(--red); }
.stat-icon.green { background: rgba(16,185,129,.1); color: var(--secondary-color); }
.stat-number { font-size: 1.75rem; font-weight: 700; color: var(--text-dark); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-light); margin-top: .35rem; }

/* Tables */
.dash-table-wrap { background: #fff; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.dash-table-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.dash-table-header h3 { font-size: 1rem; font-weight: 600; }
.dash-table { width: 100%; border-collapse: collapse; }
.dash-table th { padding: .7rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .5px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.dash-table td { padding: .7rem 1rem; font-size: .85rem; border-bottom: 1px solid #f1f5f9; }
.dash-table tr:hover { background: #f8fafc; }
.dash-table .url-cell { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dark); }
.risk-badge { display: inline-block; padding: .2rem .6rem; border-radius: 6px; font-size: .75rem; font-weight: 600; text-transform: uppercase; }
.risk-badge.high { background: rgba(239,68,68,.1); color: #dc2626; }
.risk-badge.medium, .risk-badge.suspicious { background: rgba(245,158,11,.1); color: #d97706; }
.risk-badge.low, .risk-badge.safe { background: rgba(16,185,129,.1); color: #059669; }

/* Welcome card */
.welcome-card {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: 12px; padding: 2rem; color: #fff; text-align: center; margin-top: 1.5rem;
}
.welcome-card h3 { font-size: 1.25rem; margin-bottom: .5rem; }
.welcome-card p { opacity: .85; font-size: .9rem; margin-bottom: 1.25rem; }
.welcome-card a {
  display: inline-flex; align-items: center; gap: .5rem; background: #fff; color: var(--primary-dark);
  padding: .75rem 1.5rem; border-radius: 8px; font-weight: 600; text-decoration: none;
  transition: transform .15s;
}
.welcome-card a:hover { transform: translateY(-2px); }

/* Filters */
.filter-bar { display: flex; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: center; }
.filter-btn {
  padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text-light); font-size: .8rem; cursor: pointer; transition: all .15s;
}
.filter-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.filter-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.export-btn {
  margin-left: auto; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text-dark); font-size: .8rem; cursor: pointer; display: flex; align-items: center; gap: .4rem;
}
.export-btn:hover { background: #f1f5f9; }

/* API Key */
.api-key-display {
  background: #1e293b; border-radius: 10px; padding: 1.25rem; color: #e2e8f0;
  font-family: 'Courier New', monospace; font-size: .9rem; display: flex;
  align-items: center; gap: .75rem; margin-bottom: 1.5rem;
}
.api-key-text { flex: 1; word-break: break-all; }
.api-btn {
  padding: .4rem .75rem; border-radius: 6px; border: 1px solid #475569;
  background: transparent; color: #94a3b8; cursor: pointer; font-size: .75rem;
  transition: all .15s;
}
.api-btn:hover { background: #334155; color: #fff; }
.api-btn.danger { border-color: #ef4444; color: #ef4444; }
.api-btn.danger:hover { background: #ef4444; color: #fff; }
.code-block {
  background: #1e293b; border-radius: 10px; padding: 1.25rem; color: #e2e8f0;
  font-family: 'Courier New', monospace; font-size: .8rem; white-space: pre-wrap;
  line-height: 1.6; overflow-x: auto;
}

/* Settings */
.settings-section { background: #fff; border-radius: 12px; border: 1px solid var(--border); padding: 1.5rem; margin-bottom: 1.25rem; }
.settings-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.settings-field { margin-bottom: 1rem; }
.settings-field label { display: block; font-size: .85rem; font-weight: 500; color: var(--text-light); margin-bottom: .35rem; }
.settings-field input {
  width: 100%; max-width: 400px; padding: .65rem .9rem; border: 2px solid var(--border);
  border-radius: 8px; font-size: .9rem; transition: border-color .2s; font-family: inherit;
}
.settings-field input:focus { outline: none; border-color: var(--primary-color); }
.settings-btn {
  padding: .6rem 1.25rem; border-radius: 8px; border: none; font-size: .85rem;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.settings-btn.primary { background: var(--primary-color); color: #fff; }
.settings-btn.primary:hover { background: var(--primary-dark); }
.settings-btn.danger { background: transparent; color: var(--red); border: 2px solid var(--red); }
.settings-btn.danger:hover { background: var(--red); color: #fff; }
.danger-zone { border-color: rgba(239,68,68,.3); }
.danger-zone h3 { color: var(--red); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: 1rem; }
.page-btn {
  padding: .4rem .75rem; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text-dark); font-size: .8rem; cursor: pointer;
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Charts */
.chart-container { background: #fff; border-radius: 12px; border: 1px solid var(--border); padding: 1.5rem; margin-bottom: 1.25rem; }
.chart-container h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.bar-chart { display: flex; align-items: flex-end; gap: .5rem; height: 160px; padding-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.bar-fill { width: 100%; border-radius: 6px 6px 0 0; background: var(--primary-color); min-height: 4px; transition: height .4s; }
.bar-label { font-size: .7rem; color: var(--text-light); }
.bar-value { font-size: .7rem; font-weight: 600; color: var(--text-dark); }
.risk-bars { display: flex; flex-direction: column; gap: .75rem; }
.risk-bar-row { display: flex; align-items: center; gap: .75rem; }
.risk-bar-label { width: 80px; font-size: .8rem; font-weight: 500; color: var(--text-dark); }
.risk-bar-track { flex: 1; height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.risk-bar-fill { height: 100%; border-radius: 5px; transition: width .5s; }
.risk-bar-pct { width: 40px; text-align: right; font-size: .8rem; font-weight: 600; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; padding: 2rem; max-width: 420px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box h3 { font-size: 1.1rem; margin-bottom: .75rem; }
.modal-box p { font-size: .9rem; color: var(--text-light); margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* Loading */
.dash-loading { text-align: center; padding: 3rem; color: var(--text-light); }
.dash-loading i { font-size: 1.5rem; margin-bottom: .75rem; display: block; }

/* Mobile bottom tab bar */
@media (max-width: 768px) {
  .dash-sidebar { display: none; }
  .dash-main { margin-left: 0; padding: 1rem; padding-bottom: 5rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .mobile-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    border-top: 1px solid var(--border); z-index: 100; box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  }
  .mobile-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem;
    padding: .6rem 0; font-size: .65rem; color: var(--text-light); cursor: pointer; border: none; background: none;
  }
  .mobile-tab.active { color: var(--primary-color); }
  .mobile-tab i { font-size: 1rem; }
}
@media (min-width: 769px) {
  .mobile-tabs { display: none; }
}
