/* =============================================
   Codexx OS - Application Styles
   ============================================= */

/* ============= App Layout ============= */
.app-body {
  display: flex;
  min-height: 100vh;
  background-color: var(--color-bg);
}

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #5F7FB5 0%, #4A6A9F 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.brand-logo-lg {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #5F7FB5, #7FA7D1);
  font-size: 28px;
  color: #FFFFFF;
  margin: 0 auto 14px;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.82);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
}

.nav-item i {
  width: 16px;
  text-align: center;
}

.nav-sub {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.65);
}

.sidebar-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============= Main ============= */
.main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 60px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.user-chip i {
  color: var(--color-primary);
}

.user-chip small {
  font-weight: 500;
  color: var(--color-text-muted);
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ============= Auth Pages ============= */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #F3F1EA 0%, #C7D7E9 100%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--color-surface);
  padding: 40px 36px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0 0 4px;
  color: var(--color-text);
}

.auth-brand-sub {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 12px;
  color: var(--color-text-muted);
}

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

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(95, 127, 181, 0.15);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

.form-help {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-top: 5px;
}

.form-error {
  background: #FFE8E8;
  color: #B53939;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border-left: 3px solid #D08585;
}

.form-success {
  background: #DDF5F2;
  color: #2E6F69;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border-left: 3px solid var(--color-accent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ============= Buttons ============= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.2;
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
  color: #FFFFFF;
}

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

.btn-secondary:hover {
  background: var(--color-bg);
  border-color: var(--color-border-dark);
  text-decoration: none;
  color: var(--color-text);
}

.btn-danger {
  background: #D08585;
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #B86F6F;
  color: #FFFFFF;
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
}

/* ============= Cards ============= */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ============= Stat Cards ============= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-primary);
}

.stat-card.stat-accent::before { background: var(--color-accent); }
.stat-card.stat-warning::before { background: var(--color-warning); }
.stat-card.stat-secondary::before { background: var(--color-primary-light); }
.stat-card.stat-lavender::before { background: var(--color-cosmic-sky); }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.5px;
}

.stat-value-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-left: 5px;
}

.stat-meta {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

/* ============= Page Header ============= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--color-text);
  margin: 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 4px 0 0;
}

.page-actions {
  display: flex;
  gap: 8px;
}

/* ============= Tables ============= */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

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

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

.table th {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-bg);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.table tbody tr:hover {
  background: rgba(199, 215, 233, 0.18);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ============= Badges ============= */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.badge-primary { background: rgba(95, 127, 181, 0.13); color: var(--color-primary); border-color: rgba(95, 127, 181, 0.25); }
.badge-accent { background: rgba(133, 206, 200, 0.18); color: #2E6F69; border-color: rgba(133, 206, 200, 0.4); }
.badge-warning { background: rgba(222, 210, 138, 0.25); color: #7A6E1A; border-color: rgba(222, 210, 138, 0.5); }
.badge-secondary { background: rgba(127, 167, 209, 0.18); color: #3E6494; border-color: rgba(127, 167, 209, 0.35); }
.badge-lavender { background: rgba(173, 176, 208, 0.2); color: #555884; border-color: rgba(173, 176, 208, 0.4); }
.badge-muted { background: rgba(172, 181, 174, 0.2); color: #5D6661; border-color: rgba(172, 181, 174, 0.4); }

/* ============= Progress Bar ============= */
.progress {
  width: 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-primary));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-bar.bar-accent {
  background: linear-gradient(90deg, var(--color-rinsing-rivulet), var(--color-accent));
}

.progress-bar.bar-warning {
  background: linear-gradient(90deg, #E8DCA0, var(--color-warning));
}

.progress-bar.bar-danger {
  background: linear-gradient(90deg, #E8A5A5, #D08585);
}

/* ============= Channel Badges ============= */
.channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.ch-meta { background: rgba(24, 119, 242, 0.1); color: #1877F2; }
.ch-naver { background: rgba(3, 199, 90, 0.1); color: #03C75A; }
.ch-hwahae { background: rgba(255, 89, 89, 0.1); color: #E54848; }
.ch-influencer { background: rgba(95, 127, 181, 0.13); color: var(--color-primary); }
.ch-google { background: rgba(234, 67, 53, 0.1); color: #EA4335; }
.ch-tiktok { background: rgba(0, 0, 0, 0.08); color: #111111; }
.ch-others { background: var(--color-bg); color: var(--color-text-muted); }

/* ============= Empty State ============= */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 38px;
  color: var(--color-border-dark);
  margin-bottom: 12px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 13px;
  margin-bottom: 16px;
}

/* ============= Grid layouts ============= */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

@media (max-width: 968px) {
  .grid-2, .grid-3, .grid-2-1, .form-row {
    grid-template-columns: 1fr;
  }
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
}

@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .sidebar-brand .brand-text,
  .nav-item span { display: none; }
  .main { margin-left: 64px; }
  .page-content { padding: 16px; }
}

/* ============= Modal (간단한 인라인 폼용) ============= */
.inline-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.inline-form-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--color-text);
}

/* ============= Channel Bar Chart (in dashboard) ============= */
.chart-canvas-wrap {
  position: relative;
  height: 260px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--color-primary);
}

/* ============= Filter / Action Bar ============= */
.action-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.action-bar .form-input,
.action-bar .form-select {
  width: auto;
  padding: 7px 12px;
  font-size: 13px;
}

/* ============= Util ============= */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-success { color: #2E6F69; }
.text-warning { color: #7A6E1A; }
.text-danger { color: #B53939; }
.text-primary { color: var(--color-primary); }
.font-mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; gap: 8px; }
