﻿/*  CPS Tools Platform — Shared Styles  */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f7fa;
  --white: #ffffff;
  --border: #e2e8f0;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-light: #eef2ff;
  --green: #10b981;
  --green-light: #ecfdf5;
  --red: #ef4444;
  --red-light: #fef2f2;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --sidebar-w: 240px;
  --nav-h: 60px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/*  TOPBAR  */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--nav-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.topbar-logo img { height: 32px; width: auto; }
.topbar-logo .site-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.topbar-logo .site-name span { color: var(--accent); }
.topbar-sep { width: 1px; height: 24px; background: var(--border); }
.topbar-search {
  flex: 1; max-width: 360px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px;
}
.topbar-search input {
  border: none; background: none; outline: none;
  font-family: inherit; font-size: 0.85rem; color: var(--text); width: 100%;
}
.topbar-search span { color: var(--text-3); font-size: 0.85rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/*  LAYOUT  */
.app-layout {
  display: flex;
  margin-top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
}

/*  SIDEBAR  */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--nav-h); bottom: 0; left: 0;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-section { margin-top: 8px; }
.sidebar-section:first-child { margin-top: 0; }
.sidebar-heading {
  font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); padding: 6px 10px 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.sidebar-link:hover { background: var(--bg); color: var(--text); }
.sidebar-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sidebar-link .sicon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-badge {
  margin-left: auto; font-size: 0.65rem; font-weight: 700;
  background: var(--amber-light); color: var(--amber); padding: 1px 6px; border-radius: 10px;
}
.sidebar-badge.new { background: var(--green-light); color: var(--green); }

/*  MAIN CONTENT  */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  padding: 28px 32px 60px;
}

/*  BUTTONS  */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: var(--white); border: 1px solid var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: none; border: none; color: var(--text-2); }
.btn-ghost:hover { color: var(--accent); }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 11px 26px; font-size: 0.92rem; }

/*  CARD  */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 24px; }

/*  AUTH MODAL  */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
  transform: translateY(16px); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-3); }
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); margin: 16px 24px 0; }
.modal-tab {
  padding: 10px 20px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; color: var(--text-3); background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit; transition: all 0.15s;
}
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.modal-body { padding: 20px 24px 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.88rem; font-family: inherit; color: var(--text); outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--accent); }
.form-note { font-size: 0.75rem; color: var(--text-3); margin-top: 12px; text-align: center; }
.form-note a { color: var(--accent); text-decoration: none; }

/*  USER AVATAR  */
.user-menu {
  position: relative;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: white; cursor: pointer;
  border: none;
}
.user-dropdown {
  position: absolute; top: 42px; right: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 180px; overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(6px); transition: all 0.15s;
}
.user-dropdown.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: 0.83rem; color: var(--text-2);
  cursor: pointer; text-decoration: none; transition: background 0.1s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--red); }
.dropdown-sep { height: 1px; background: var(--border); }
.plan-badge {
  font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 8px; margin-left: auto;
}
.plan-badge.free { background: var(--bg); color: var(--text-3); }
.plan-badge.pro { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: white; }

/*  USAGE BAR  */
.usage-bar-wrap { margin-bottom: 20px; }
.usage-bar-label { font-size: 0.78rem; color: var(--text-3); margin-bottom: 6px; display: flex; justify-content: space-between; }
.usage-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.usage-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s; }

/*  BREADCRUMB  */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-3); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }

/*  RESPONSIVE  */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px 60px; }
}