/* ======================================
   Packaging Catalog Online - Shared Styles
   Milott Laboratories
   ====================================== */

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

:root {
  --green-primary: #0a8f40;
  --green-dark: #0d6e36;
  --green-light: #5fc785;
  --green-bg: #f0f8f3;
  --gray-50: #f8faf9;
  --gray-100: #eef2f0;
  --gray-200: #d9e6dd;
  --gray-300: #c0d0c5;
  --gray-500: #6c7a70;
  --gray-700: #2c3e34;
  --gray-900: #1a2e1f;
  --red: #dc3545;
  --orange: #fd7e14;
  --yellow: #ffc107;
  --blue: #4a89dc;
  --purple: #6f42c1;
}

body {
  font-family: 'Segoe UI', 'Sarabun', Tahoma, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  font-size: 14px;
}

/* ===== Layout ===== */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  background: linear-gradient(180deg, #0d6e36 0%, #074d24 100%);
  color: white;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}
.sidebar-logo .brand {
  font-size: 18px;
  font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.sidebar-logo .brand .leaf { font-size: 20px; }
.sidebar-logo .tagline {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}
.sidebar-nav { padding: 0 12px; }
.sidebar-nav .section-title {
  font-size: 10px;
  text-transform: uppercase;
  opacity: 0.5;
  padding: 12px 12px 6px;
  letter-spacing: 1px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  margin: 2px 0;
  transition: background 0.15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.1); }
.sidebar-nav a.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 600;
}
.sidebar-nav .icon { font-size: 16px; width: 20px; text-align: center; }

/* ===== Main / Topbar ===== */
.main-area { display: flex; flex-direction: column; }
.topbar {
  background: white;
  padding: 14px 32px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .breadcrumb {
  font-size: 13px;
  color: var(--gray-500);
}
.topbar .breadcrumb a {
  color: var(--green-primary);
  text-decoration: none;
}
.topbar .breadcrumb a:hover { text-decoration: underline; }
.topbar-user {
  display: flex; align-items: center; gap: 14px;
}
.topbar-user .role-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--green-bg);
  color: var(--green-dark);
}
.topbar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--green-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 13px;
}
.topbar-user a { color: var(--gray-500); text-decoration: none; font-size: 13px; }
.topbar-user a:hover { color: var(--red); }

/* ===== Page ===== */
.page {
  padding: 28px 32px;
  flex: 1;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 24px;
  color: var(--green-dark);
  font-weight: 700;
}
.page-subtitle {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--green-primary); color: white; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: white; color: var(--green-dark); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b02a37; }
.btn-warn { background: var(--yellow); color: #5a4500; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ===== Cards ===== */
.card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

/* ===== Stats ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  padding: 18px 20px;
  border-radius: 10px;
  border-left: 4px solid var(--green-primary);
}
.stat-card.blue { border-left-color: var(--blue); }
.stat-card.orange { border-left-color: var(--orange); }
.stat-card.purple { border-left-color: var(--purple); }
.stat-card.red { border-left-color: var(--red); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: var(--green-dark);
  color: white;
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table thead th:first-child { border-top-left-radius: 8px; }
.data-table thead th:last-child { border-top-right-radius: 8px; }
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table a { color: var(--green-primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* ===== Status Badges ===== */
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.status-accept, .status-done, .status-active { background: #d4edda; color: #155724; }
.status-reject, .status-blacklist { background: #f8d7da; color: #721c24; }
.status-process, .status-pending { background: #fff3cd; color: #856404; }
.status-new { background: #d1ecf1; color: #0c5460; }
.status-discontinued { background: #e2e3e5; color: #383d41; }

/* Performance Rating Colors */
.rating-excellence { color: #1d8348; font-weight: 700; }
.rating-good { color: #82c43c; font-weight: 700; }
.rating-fair { color: #e6a23c; font-weight: 700; }
.rating-improvement { color: #f56c6c; font-weight: 700; }
.rating-blacklist { color: #c0392b; font-weight: 700; }
.rating-new { color: #3498db; font-weight: 700; }
.rating-na { color: #909399; font-weight: 700; }

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12px;
  color: var(--gray-700);
  font-weight: 600;
}
.form-group label .req { color: var(--red); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(10,143,64,0.1);
}
.form-group .hint { font-size: 11px; color: var(--gray-500); }
.form-group.full { grid-column: 1 / -1; }
.checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-group label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 400;
  cursor: pointer;
}

/* ===== Search Bar ===== */
.search-bar {
  display: flex; gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-bar input,
.search-bar select {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}
.search-bar input { flex: 1; min-width: 200px; }

/* ===== Filters Panel ===== */
.filters-panel {
  background: white;
  padding: 16px 20px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

/* ===== Product Categories Cards ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.cat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  border: 2px solid transparent;
  transition: all 0.2s;
  display: block;
}
.cat-card:hover {
  border-color: var(--green-primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(10,143,64,0.1);
}
.cat-card .cat-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.cat-card .cat-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--green-dark);
}
.cat-card .cat-count {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Packaging Category icon strip */
.pkg-cat-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 16px;
  background: white;
  border-radius: 12px;
  margin-bottom: 20px;
}
.pkg-cat-tile {
  min-width: 90px;
  text-align: center;
  padding: 12px 8px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: var(--gray-700);
}
.pkg-cat-tile:hover { background: var(--green-bg); }
.pkg-cat-tile.active {
  border-color: var(--green-primary);
  background: var(--green-bg);
}
.pkg-cat-tile .icon { font-size: 24px; }
.pkg-cat-tile .label { font-size: 11px; margin-top: 4px; }

/* ===== Item Grid (Packaging items) ===== */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.item-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  border: 1px solid var(--gray-200);
}
.item-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.item-img {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #e8f5ec 0%, #c8e6cf 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 56px;
  position: relative;
}
.item-img .blacklist-overlay {
  position: absolute;
  top: 50%; left: 0; right: 0;
  text-align: center;
  background: rgba(220, 53, 69, 0.85);
  color: white;
  font-weight: 700;
  padding: 4px;
  font-size: 13px;
  letter-spacing: 2px;
  transform: translateY(-50%) rotate(-15deg);
}
.item-info {
  padding: 12px 14px;
}
.item-code {
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: var(--green-primary);
  font-weight: 700;
}
.item-name {
  font-size: 13px;
  margin-top: 4px;
  font-weight: 600;
}

/* ===== Detail page layout ===== */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 28px;
}
@media (max-width: 900px) { .detail-layout { grid-template-columns: 1fr; } }

.detail-img-main {
  background: linear-gradient(135deg, #e8f5ec 0%, #c8e6cf 100%);
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 120px;
  margin-bottom: 12px;
}
.detail-thumbs { display: flex; gap: 8px; }
.detail-thumb {
  width: 70px; height: 70px;
  background: var(--green-bg);
  border-radius: 8px;
  border: 2px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  cursor: pointer;
}
.detail-thumb.active { border-color: var(--green-primary); }

.spec-table {
  width: 100%;
  border-collapse: collapse;
}
.spec-table tr td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.spec-table tr td:first-child {
  background: var(--green-bg);
  font-weight: 600;
  color: var(--green-dark);
  width: 40%;
}
.spec-table .section-row td {
  background: var(--green-dark);
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}
.spec-table .check { color: var(--green-primary); font-size: 18px; }
.spec-table .cross { color: var(--red); font-size: 18px; }

.action-row {
  display: flex; gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--green-bg);
  color: var(--green-dark);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
  text-decoration: none;
  cursor: pointer;
}
.tag:hover { background: var(--green-light); color: white; }

/* ===== Workflow timeline ===== */
.timeline {
  display: flex; flex-direction: column;
  gap: 0;
  padding: 12px 0;
}
.timeline-step {
  display: flex; gap: 14px;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 3px solid var(--gray-300);
}
.timeline-step.done { border-left-color: var(--green-primary); background: #f0f8f3; }
.timeline-step.current { border-left-color: var(--yellow); background: #fffbeb; }
.timeline-step.pending { opacity: 0.6; }
.timeline-step .step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gray-300);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.timeline-step.done .step-num { background: var(--green-primary); }
.timeline-step.current .step-num { background: var(--yellow); color: #5a4500; }
.timeline-step .step-content { flex: 1; font-size: 13px; }
.timeline-step .step-title { font-weight: 600; color: var(--gray-900); }
.timeline-step .step-meta { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
}
.tab {
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-500);
  text-decoration: none;
}
.tab.active { color: var(--green-primary); border-bottom-color: var(--green-primary); }

/* ===== Login Page ===== */
.login-bg {
  background: linear-gradient(135deg, #0a8f40 0%, #0d6e36 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: white;
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.login-card .brand {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--green-primary);
}
.login-card .tag {
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 28px;
  background: none;
  padding: 0;
}
.login-card h1 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--gray-900);
}
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn-block {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 8px;
}
.login-card .links {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.login-card .links a {
  color: var(--green-primary);
  text-decoration: none;
}
.login-card .demo-info {
  background: var(--green-bg);
  padding: 12px;
  border-radius: 8px;
  font-size: 11px;
  margin-top: 18px;
  color: var(--gray-700);
}
.login-card .demo-info b { color: var(--green-dark); }

/* ===== Misc ===== */
.note {
  background: #fff3cd;
  border-left: 3px solid var(--yellow);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: #856404;
  margin: 12px 0;
}
.note.info {
  background: #d1ecf1;
  border-left-color: #17a2b8;
  color: #0c5460;
}
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}
.empty .icon { font-size: 56px; margin-bottom: 12px; }

.role-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: white;
  margin: 2px;
}
.role-pill.customer { background: #6c757d; }
.role-pill.cts { background: #0a8f40; }
.role-pill.supplier { background: #fd7e14; }
.role-pill.tpk { background: #6f42c1; }
.role-pill.pur { background: #e83e8c; }
.role-pill.sourcing { background: #20c997; }
.role-pill.admin { background: #dc3545; }

/* responsive */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .page { padding: 16px; }
}
