/* ============================================
   Sample CRM Demo - Style System
   ============================================ */

:root {
  /* Brand Colors */
  --primary: #7C3AED;
  --primary-light: #8B5CF6;
  --primary-dark: #6D28D9;
  --primary-50: #F5F3FF;
  --primary-100: #EDE9FE;

  /* Accent */
  --accent: #F97316;
  --accent-light: #FB923C;

  /* Status Colors */
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;

  /* Grays */
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 60px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background-color: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

/* Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
  color: var(--white);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
}

.sidebar-logo span {
  color: var(--primary-light);
  font-weight: 400;
  font-size: 14px;
  margin-left: 4px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.nav-group-toggle:hover {
  color: var(--white);
}

.nav-group-icon {
  opacity: 0.7;
}

.nav-group-arrow {
  margin-left: auto;
  transition: transform var(--transition-fast);
}

.nav-group.expanded .nav-group-arrow {
  transform: rotate(180deg);
}

.nav-group-items {
  list-style: none;
  display: none;
  padding: 0 0 8px 0;
}

.nav-group.expanded .nav-group-items {
  display: block;
}

.nav-group-items a {
  display: block;
  padding: 10px 20px 10px 52px;
  color: var(--gray-400);
  font-size: 14px;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

.nav-group-items a:hover {
  color: var(--white);
  background: rgba(255,255,255,0.05);
}

.nav-group-items a.active {
  color: var(--white);
  background: rgba(124, 58, 237, 0.2);
  border-left-color: var(--primary);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
}

.sidebar-logout {
  font-size: 12px;
  color: var(--gray-400);
}

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  max-width: calc(100% - var(--sidebar-width));
  overflow-x: hidden;
}

.admin-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
}

.admin-content {
  padding: 24px;
}

/* Demo Badge */
.demo-badge {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--accent);
  color: var(--white);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--primary-100);
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.kpi-card.accent::before {
  background: var(--accent);
}

.kpi-card.success::before {
  background: var(--success);
}

.kpi-card.info::before {
  background: var(--info);
}

.kpi-label {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.kpi-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--gray-500);
}

.kpi-change {
  font-size: 13px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-change.positive {
  color: var(--success);
}

.kpi-change.negative {
  color: var(--danger);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

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

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--gray-50);
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-primary {
  background: var(--primary-100);
  color: var(--primary);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-gray {
  background: var(--gray-200);
  color: var(--gray-600);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

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

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar select,
.filter-bar input {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  background: var(--white);
  color: var(--gray-800);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* Period Selector */
.period-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.period-btn {
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-600);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.period-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.period-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Charts Container */
.chart-container {
  position: relative;
  height: 300px;
  margin-bottom: 20px;
}

.chart-container canvas {
  max-width: 100%;
}

/* Bar Chart (CSS-based) */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  padding: 20px 0;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bar {
  width: 100%;
  max-width: 60px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease-out;
  position: relative;
}

.bar:hover {
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.bar-value {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

.bar-label {
  font-size: 11px;
  color: var(--gray-500);
  text-align: center;
}

/* Percentage Bar */
.percent-bar {
  height: 24px;
  background: var(--gray-100);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
}

.percent-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  transition: width 0.5s ease-out;
}

.percent-segment.gold {
  background: linear-gradient(90deg, #F59E0B 0%, #FBBF24 100%);
}

.percent-segment.silver {
  background: linear-gradient(90deg, #6B7280 0%, #9CA3AF 100%);
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.stat-item {
  text-align: center;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 8px;
}

.stat-item-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-item-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Production Status Grid */
.production-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.production-status-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.production-status-card.pending {
  border-left: 4px solid var(--gray-400);
}

.production-status-card.in-progress {
  border-left: 4px solid var(--info);
}

.production-status-card.completed {
  border-left: 4px solid var(--success);
}

.production-status-card.shipped {
  border-left: 4px solid var(--primary);
}

.production-status-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

.production-status-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Inventory Card */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.inventory-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 24px;
}

.inventory-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inventory-card h3 .icon-gold {
  color: #F59E0B;
}

.inventory-card h3 .icon-silver {
  color: #6B7280;
}

.inventory-value {
  font-size: 48px;
  font-weight: 700;
  color: var(--gray-900);
}

.inventory-unit {
  font-size: 16px;
  font-weight: 400;
  color: var(--gray-500);
}

.inventory-status {
  margin-top: 12px;
  font-size: 13px;
}

.inventory-status.ok {
  color: var(--success);
}

.inventory-status.warning {
  color: var(--warning);
}

.inventory-status.danger {
  color: var(--danger);
}

/* Mobile Header */
.mobile-header {
  display: none;
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1001;
}

.mobile-logo {
  font-size: 18px;
  font-weight: 700;
}

.mobile-logo span {
  color: var(--primary-light);
  font-size: 12px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 8px;
}

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

  .production-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .inventory-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
    max-width: 100%;
  }

  .admin-header {
    display: none;
  }

  .admin-content {
    padding: 16px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .kpi-value {
    font-size: 24px;
  }

  .production-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .period-selector {
    width: 100%;
    overflow-x: auto;
  }

  table {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: block;
  }

  tr {
    display: block;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px;
  }

  td {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
  }

  .demo-badge {
    top: auto;
    bottom: 16px;
    right: 16px;
  }
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

.sidebar-overlay.open {
  display: block;
}

/* Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.3s ease-out;
}

@keyframes countUp {
  from { opacity: 0; }
  to { opacity: 1; }
}

.kpi-value {
  animation: countUp 0.5s ease-out;
}

/* Back to Case Study Link */
.back-to-case {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-500);
  font-size: 13px;
  margin-bottom: 16px;
  transition: color var(--transition-fast);
}

.back-to-case:hover {
  color: var(--primary);
}
