/* Sifu Internal Platform — Main Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Light Theme (default) ──────────────────────────── */
:root {
  --brand: #2563EB;
  --brand-dark: #1E40AF;
  --brand-muted: #EFF6FF;
  --brand-accent: #7C3AED;
  --bg: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-hover: #F8FAFC;
  --border: #E2E8F0;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --sidebar-w: 220px;
  --priority-high: #EF4444;
  --priority-medium: #F59E0B;
  --priority-low: #10B981;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.1);
}

/* ── Dark Theme ─────────────────────────────────────── */
[data-theme="dark"] {
  --brand: #3B82F6;
  --brand-dark: #93C5FD;
  --brand-muted: #1E3A5F;
  --bg: #0F172A;
  --bg-card: #1E293B;
  --bg-hover: #273549;
  --border: #334155;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.5);
}
[data-theme="dark"] .sidebar { background: var(--bg-card); }
[data-theme="dark"] .topbar  { background: var(--bg-card); }
[data-theme="dark"] .kanban-card { background: var(--bg-card); }
[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=password],
[data-theme="dark"] input[type=date],
[data-theme="dark"] input[type=time],
[data-theme="dark"] input[type=email],
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--bg-hover); border-color: var(--border); color: var(--text-primary); }

body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text-primary); font-size: 14px; line-height: 1.5; transition: background .2s, color .2s; }
a { color: inherit; text-decoration: none; }

/* ── App Shell ──────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 50;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 32px; height: 32px; background: var(--brand); color: #fff;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.logo-text { font-weight: 700; font-size: 15px; color: var(--brand-dark); }
.logo-sub { font-weight: 400; font-size: 11px; color: var(--text-muted); margin-left: 4px; }

.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-secondary); font-size: 13px; font-weight: 500; transition: all .15s;
}
.nav-item:hover { background: var(--brand-muted); color: var(--brand); }
.nav-item.active { background: var(--brand-muted); color: var(--brand); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }

.sidebar-user {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.logout-btn { color: var(--text-muted); padding: 4px; border-radius: 6px; transition: .15s; }
.logout-btn:hover { color: var(--priority-high); background: #FEE2E2; }

/* ── Topbar ─────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between;
}
.page-title { font-size: 17px; font-weight: 700; color: var(--brand-dark); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Theme & Lang toggle */
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-secondary); display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: .15s; font-size: 14px;
}
.icon-btn:hover { background: var(--brand-muted); color: var(--brand); border-color: var(--brand); }
.lang-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: .15s;
  font-family: inherit;
}
.lang-toggle:hover { background: var(--brand-muted); color: var(--brand); border-color: var(--brand); }

.page-body { padding: 24px; max-width: 1100px; }

/* ── Avatar ─────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* ── Cards ──────────────────────────────────────────── */
.card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); transition: all .15s; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #FEE2E2; color: var(--priority-high); }
.btn-danger:hover { background: var(--priority-high); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--brand-muted); color: var(--brand); border: 1px solid var(--border); }

/* ── Forms ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=email],
select, textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: var(--bg-card); color: var(--text-primary);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea { resize: vertical; min-height: 80px; }

/* ── Alerts ─────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }

/* ── Table ──────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; text-align: left; background: var(--bg); border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* ── Stats Grid ─────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card { padding: 16px; display: flex; align-items: center; gap: 12px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── List Items ─────────────────────────────────────── */
.list-item { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); transition: background .1s; text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-hover); }

/* ── Date Badge ─────────────────────────────────────── */
.date-badge { width: 44px; height: 44px; border-radius: 10px; background: var(--brand-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.date-badge .day { font-size: 17px; font-weight: 700; color: var(--brand); line-height: 1; }
.date-badge .month { font-size: 10px; color: var(--brand); }

/* ── Section / Page Headers ─────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 18px; font-weight: 700; color: var(--brand-dark); }
.page-header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Filter Bar ─────────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.filter-bar input, .filter-bar select { padding: 6px 10px; font-size: 12px; min-width: 120px; }
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-wrap input { padding-left: 28px; }

/* ── Detail Page ────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.detail-meta { display: flex; flex-direction: column; gap: 12px; }
.meta-item { display: flex; flex-direction: column; gap: 3px; }
.meta-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.meta-value { font-size: 13px; color: var(--text-primary); }
.description-box { padding: 16px; font-size: 13px; line-height: 1.7; color: var(--text-primary); white-space: pre-wrap; }
.notes-content { padding: 16px; font-size: 13px; line-height: 1.8; }
.notes-content h2 { font-size: 16px; font-weight: 700; margin: 0 0 10px; color: var(--brand-dark); }
.notes-content h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; color: var(--text-primary); }
.notes-content p { margin-bottom: 8px; }
.notes-content ul, .notes-content ol { padding-left: 20px; margin-bottom: 8px; }
.notes-content li { margin-bottom: 4px; }
.notes-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; border: 1px solid var(--border); }
.notes-content table { margin: 10px 0; }

/* ── Comments ───────────────────────────────────────── */
.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-body { flex: 1; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-author { font-size: 12px; font-weight: 600; }
.comment-time { font-size: 11px; color: var(--text-muted); }
.comment-text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.comment-form textarea { width: 100%; margin-bottom: 8px; }

/* ── Login ──────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 360px; padding: 36px 32px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; justify-content: center; }
.login-title { font-size: 20px; font-weight: 700; color: var(--brand-dark); }

/* ── Kanban ─────────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kanban-col { background: var(--bg); border-radius: var(--radius); padding: 10px; }
.kanban-col-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; padding: 4px 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.kanban-count { background: var(--border); border-radius: 999px; padding: 1px 7px; font-size: 11px; }
.kanban-card { background: var(--bg-card); border-radius: 8px; padding: 12px; margin-bottom: 8px; border: 1px solid var(--border); box-shadow: var(--shadow); cursor: pointer; transition: .15s; display: block; }
.kanban-card:hover { box-shadow: var(--shadow-lg); }
.kanban-card-title { font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 8px; line-height: 1.4; }

/* ── Admin ──────────────────────────────────────────── */
.admin-section { max-width: 700px; }

/* ── i18n hidden ────────────────────────────────────── */
[data-lang="en"] .zh { display: none !important; }
[data-lang="zh"] .en { display: none !important; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .page-body { padding: 16px; }
}
