/* 🦑 징어증권 (Squid Securities) Master CSS Theme */

@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@400;500;600;700;800&display=swap');

:root {
  --bg-app: #d8b4f8;
  --bg-main: #dfc2f9;
  --bg-sidebar: #d4aef8;
  --sidebar-hover: #c99af5;
  --sidebar-active: #bc82f3;
  --card-bg: #f5e8ff;
  --card-shadow: 0 8px 24px rgba(138, 75, 205, 0.08);
  --text-main: #1f1926;
  --text-muted: #6b5b7b;
  --accent-purple: #8b3dff;
  --accent-red: #e11d48;
  --accent-green: #22c55e;
  --accent-green-line: #4ade80;
  --border-subtle: #cca3f5;
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ----------------------------------------------------
   SIDEBAR (시안 1 구현)
---------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 2px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 10;
  user-select: none;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  padding: 24px 8px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 8px;
}

.sidebar-brand {
  font-size: 22px;
  font-weight: 800;
  color: #111;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.sidebar-brand .squid-icon {
  font-size: 28px;
}

.sidebar.collapsed .sidebar-brand span {
  display: none;
}

/* Toggle Collapse Button */
.toggle-btn {
  position: absolute;
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background-color: #c495f0;
  color: #111;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
  border: 2px solid var(--bg-main);
  z-index: 20;
}

.toggle-btn:hover {
  background-color: #b37de8;
  transform: translateY(-50%) scale(1.1);
}

/* Navigation Menu Items */
.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 17px;
  color: #1a1625;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
}

.nav-item.active {
  background-color: var(--sidebar-active);
  color: #000;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.15);
}

.nav-item .icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item span {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 14px 0;
}

/* ----------------------------------------------------
   MAIN CONTENT AREA (시안 2 구현)
---------------------------------------------------- */
.main-content {
  flex: 1;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 36px;
  position: relative;
}

/* Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 800;
  color: #111;
}

.user-status {
  font-size: 15px;
  font-weight: 700;
  color: #222;
  background: rgba(255, 255, 255, 0.4);
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-status:hover {
  background: rgba(255, 255, 255, 0.7);
}

/* News Banner Ticker */
.news-ticker-container {
  background-color: var(--card-bg);
  border-radius: 24px;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  margin-bottom: 32px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  overflow: hidden;
  height: 60px;
  position: relative;
}

.news-label {
  color: #4a385f;
  margin-right: 12px;
}

.news-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-badge {
  background: #e9d5ff;
  color: #7c3aed;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
}

/* ----------------------------------------------------
   STOCK CARDS GRID (시안 2 마켓 카드리스트)
---------------------------------------------------- */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .stock-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .stock-grid {
    grid-template-columns: 1fr;
  }
}

.stock-card {
  background-color: var(--card-bg);
  border-radius: 24px;
  padding: 20px 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 200px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  position: relative;
}

.stock-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(138, 75, 205, 0.18);
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stock-name {
  font-size: 18px;
  font-weight: 800;
  color: #1a1625;
}

.stock-change {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-red);
}

.stock-change.negative {
  color: #2563eb;
}

.stock-price-sub {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.stock-chart-wrapper {
  width: 100%;
  height: 110px;
  position: relative;
  margin-top: 8px;
}

/* ----------------------------------------------------
   MANAGEMENT TABS (학생/종목/시장/거래/공지/수수료/설정)
---------------------------------------------------- */
.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-panel {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
}

/* Tables */
.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.custom-table th, .custom-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(138, 75, 205, 0.12);
  font-size: 15px;
}

.custom-table th {
  font-weight: 700;
  color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.4);
}

.custom-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.5);
}

/* Buttons & Inputs */
.btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent-purple);
  color: white;
}

.btn-primary:hover {
  background: #7928ca;
}

.btn-success {
  background: var(--accent-green);
  color: white;
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-secondary {
  background: #e9d5ff;
  color: #4c1d95;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
}

.form-control {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: white;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-purple);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #f8f0ff;
  width: 90%;
  max-width: 500px;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
}

.modal-close {
  cursor: pointer;
  font-size: 24px;
  color: #666;
}

/* Sparkline SVG styling */
.sparkline-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sparkline-path {
  fill: none;
  stroke: var(--accent-green-line);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(74, 222, 128, 0.4));
}

/* ----------------------------------------------------
   STUDENT BALANCES OVERVIEW TAB (학생 잔고 현황)
---------------------------------------------------- */
.overview-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 18px 22px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(138, 75, 205, 0.12);
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card-icon {
  font-size: 24px;
  margin-bottom: 2px;
}

.stat-card-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-card-value {
  font-size: 22px;
  font-weight: 800;
  color: #1a1625;
}

.stat-card-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Filter & Search Bar */
.overview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  background: var(--card-bg);
  padding: 14px 20px;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}

.search-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

.view-mode-toggle {
  display: flex;
  background: rgba(223, 194, 249, 0.4);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.view-mode-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-mode-btn.active {
  background: #c4b5fd;
  color: #1e1b4b;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.15);
}

/* Student Balance Cards Grid */
.balance-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.balance-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(138, 75, 205, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.balance-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(138, 75, 205, 0.16);
}

.balance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.balance-card-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 14px;
  background: #e9d5ff;
  color: #6b21a8;
}

.rank-1 { background: #fef08a; color: #854d0e; font-size: 16px; box-shadow: 0 0 10px rgba(250, 204, 21, 0.5); }
.rank-2 { background: #e2e8f0; color: #334155; font-size: 16px; }
.rank-3 { background: #fed7aa; color: #9a3412; font-size: 16px; }

.balance-card-name {
  font-size: 17px;
  font-weight: 800;
  color: #1a1625;
}

.balance-card-num {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.total-asset-badge {
  text-align: right;
}

.total-asset-val {
  font-size: 19px;
  font-weight: 800;
  color: var(--accent-purple);
}

.asset-ratio-bar {
  height: 8px;
  width: 100%;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  margin: 12px 0 14px 0;
}

.ratio-cash {
  background: #a855f7;
  transition: width 0.3s ease;
}

.ratio-stock {
  background: #3b82f6;
  transition: width 0.3s ease;
}

.balance-card-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(255, 255, 255, 0.45);
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
}

.breakdown-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.breakdown-value {
  font-size: 14px;
  font-weight: 800;
}

.holdings-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 28px;
  align-items: center;
}

.holding-chip {
  background: #e0e7ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid #c7d2fe;
}

.no-holdings-tag {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.balance-card-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(138, 75, 205, 0.1);
  padding-top: 12px;
}
