/* =============================================
   CyberWatch Japan – Main Stylesheet
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
  --bg-base:       #0a0e1a;
  --bg-card:       #111627;
  --bg-card-hover: #161d35;
  --bg-modal:      #0d1120;
  --accent:        #00d4ff;
  --accent-dim:    rgba(0, 212, 255, 0.15);
  --accent-glow:   rgba(0, 212, 255, 0.35);
  --green:         #00e676;
  --yellow:        #ffc107;
  --orange:        #ff6d00;
  --red:           #ff1744;
  --purple:        #b388ff;
  --text-primary:  #e8eaf6;
  --text-secondary:#8896b3;
  --text-muted:    #4a5568;
  --border:        rgba(255,255,255,0.07);
  --border-bright: rgba(0,212,255,0.3);
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 4px 24px rgba(0,0,0,0.45);
  --shadow-card:   0 2px 16px rgba(0,0,0,0.35);
  --transition:    0.22s ease;
  --font-mono:     'JetBrains Mono', monospace;
  --font-sans:     'Inter', sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }
.hidden { display: none !important; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* =============================================
   HEADER
   ============================================= */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
  flex-wrap: wrap;
}

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #00d4ff 0%, #0066ff 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}
.brand-name { font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.brand-sub  { font-size: 11px; color: var(--text-secondary); display: block; letter-spacing: 2px; text-transform: uppercase; }

/* Nav */
#main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.nav-btn {
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 1px solid transparent;
}
.nav-btn:hover { color: var(--text-primary); background: var(--accent-dim); }
.nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--border-bright);
}

/* Search & actions */
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#search-wrapper {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 7px 14px;
  transition: var(--transition);
}
#search-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
#search-wrapper i { color: var(--text-muted); font-size: 13px; }
#search-input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px; width: 180px;
}
#search-input::placeholder { color: var(--text-muted); }

#add-news-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d4ff, #0066ff);
  color: #fff;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  box-shadow: 0 0 12px var(--accent-glow);
}
#add-news-btn:hover { transform: scale(1.1); box-shadow: 0 0 20px var(--accent-glow); }

/* =============================================
   STATS BAR
   ============================================= */
#stats-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px 32px;
  max-width: 1440px;
  margin: 0 auto;
  overflow-x: auto;
}
.stat-item { text-align: center; flex-shrink: 0; }
.stat-value {
  display: block;
  font-size: 28px; font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
}
.stat-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.stat-item.critical .stat-value { color: var(--red); }
.stat-item.high     .stat-value { color: var(--orange); }
.stat-item.medium   .stat-value { color: var(--yellow); }
.stat-divider { width: 1px; height: 40px; background: var(--border); flex-shrink: 0; }
.stat-chart-wrapper { flex: 1; min-width: 220px; max-width: 380px; height: 80px; }
.stat-chart-wrapper canvas { width: 100% !important; height: 80px !important; }

/* =============================================
   MAIN CONTENT
   ============================================= */
#main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.section-title {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.section-title i { color: var(--accent); }

/* =============================================
   FEATURED GRID
   ============================================= */
#featured-section { margin-bottom: 40px; }

#featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.featured-card {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.featured-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), #0066ff);
}
.featured-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

/* =============================================
   NEWS GRID
   ============================================= */
.news-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap; gap: 10px;
}
.sort-wrapper {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
}
.sort-wrapper select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 5px 10px;
  font-size: 13px;
  outline: none;
}
.sort-wrapper select:focus { border-color: var(--accent); }

#news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ---------- News Card ---------- */
.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
.news-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

/* Severity left border */
.news-card.sev-critical { border-left: 3px solid var(--red); }
.news-card.sev-high     { border-left: 3px solid var(--orange); }
.news-card.sev-medium   { border-left: 3px solid var(--yellow); }
.news-card.sev-low      { border-left: 3px solid var(--green); }
.news-card.sev-info     { border-left: 3px solid var(--purple); }

/* Card meta row */
.card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.badge-severity {
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase;
  font-family: var(--font-mono);
}
.badge-severity.sev-critical { background: rgba(255,23,68,0.2); color: var(--red); }
.badge-severity.sev-high     { background: rgba(255,109,0,0.2); color: var(--orange); }
.badge-severity.sev-medium   { background: rgba(255,193,7,0.2);  color: var(--yellow); }
.badge-severity.sev-low      { background: rgba(0,230,118,0.2);  color: var(--green); }
.badge-severity.sev-info     { background: rgba(179,136,255,0.2);color: var(--purple); }

.badge-topic {
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 11px; font-weight: 500;
  background: var(--accent-dim);
  color: var(--accent);
}
.card-date {
  margin-left: auto;
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
}

.card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary); line-height: 1.5;
}
.card-summary {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.card-source {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.card-source i { font-size: 10px; }
.card-tags {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.tag {
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* =============================================
   LOAD MORE
   ============================================= */
#load-more-wrapper { text-align: center; margin-top: 28px; }
#load-more-btn {
  padding: 10px 32px;
  border-radius: 24px;
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
  color: var(--accent);
  font-size: 14px; font-weight: 600;
  transition: var(--transition);
}
#load-more-btn:hover { background: var(--accent-dim); box-shadow: 0 0 16px var(--accent-glow); }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 16px; }

/* =============================================
   MODAL
   ============================================= */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative; z-index: 1;
  background: var(--bg-modal);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%; max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* Detail Modal */
#detail-content .detail-severity-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
#detail-content .detail-title {
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  line-height: 1.45; margin-bottom: 16px;
}
#detail-content .detail-summary {
  font-size: 14px; color: var(--text-secondary);
  line-height: 1.8; margin-bottom: 20px;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}
#detail-content .detail-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 20px;
}
.detail-meta-item label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 4px; }
.detail-meta-item span  { font-size: 13px; color: var(--text-primary); font-weight: 500; }
#detail-content .detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
#detail-content .detail-tag {
  padding: 4px 10px; border-radius: 5px;
  background: rgba(0,212,255,0.1); color: var(--accent);
  font-size: 12px; font-family: var(--font-mono);
  border: 1px solid rgba(0,212,255,0.2);
}
#detail-content .detail-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0066ff);
  color: #fff !important; font-size: 13px; font-weight: 600;
  text-decoration: none !important;
  transition: var(--transition);
}
#detail-content .detail-link:hover { opacity: 0.85; transform: translateY(-1px); }
.detail-actions { display: flex; gap: 10px; align-items: center; }
.btn-delete-news {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  background: rgba(255,23,68,0.1);
  color: var(--red);
  font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,23,68,0.3);
  transition: var(--transition);
}
.btn-delete-news:hover { background: rgba(255,23,68,0.2); }

/* Add Form */
.form-box h2 {
  font-size: 18px; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
  color: var(--accent);
}
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group .required { color: var(--red); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-group textarea { resize: vertical; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.checkbox-group input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.btn-primary {
  padding: 10px 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0066ff);
  color: #fff; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: var(--transition);
}
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }

.btn-secondary {
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* =============================================
   TOAST
   ============================================= */
#toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 999;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: fadeIn 0.25s ease;
  min-width: 220px;
  display: flex; align-items: center; gap: 8px;
}
#toast.success { border-color: var(--green); }
#toast.success i { color: var(--green); }
#toast.error   { border-color: var(--red); }
#toast.error   i { color: var(--red); }
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* =============================================
   SKELETON LOADER
   ============================================= */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.sk-line { height: 12px; }
.sk-line.w30 { width: 30%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-line.w100{ width: 100%; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .header-inner { height: auto; padding: 10px 16px; }
  #main-nav { display: none; }
  #main-content { padding: 20px 16px 40px; }
  #stats-bar { padding: 12px 16px; gap: 16px; }
  .stat-chart-wrapper { min-width: 160px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-meta { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  #search-input { width: 120px; }
  .modal-box { padding: 20px; }
  #news-grid { grid-template-columns: 1fr; }
}
