/*
 * York Imperial Plastics — assets/core.css
 * Light theme: cool off-white content, light gray sidebar, YIP green accent.
 */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* Shell */
  --yip-shell-bg:     #f0f2f5;
  --yip-sidebar-bg:   #e4e7ec;
  --yip-sidebar-w:    220px;
  --yip-topbar-h:     48px;

  /* Surface */
  --yip-surface:      #ffffff;
  --yip-surface-2:    #f7f8fa;
  --yip-border:       #d1d5db;
  --yip-border-light: #e5e7eb;

  /* Text */
  --yip-text:         #1a1f2e;
  --yip-text-muted:   #6b7280;
  --yip-text-dim:     #9ca3af;
  --yip-text-invert:  #ffffff;

  /* Accent — YIP green */
  --yip-accent:       #4DAA6A;
  --yip-accent-dark:  #3a8652;
  --yip-accent-glow:  rgba(77, 170, 106, 0.12);

  /* Status */
  --yip-green:        #2e7d32;
  --yip-green-bg:     #e8f5e9;
  --yip-red:          #c62828;
  --yip-red-bg:       #ffebee;
  --yip-yellow:       #e65100;
  --yip-yellow-bg:    #fff3e0;
  --yip-blue:         #1565c0;
  --yip-blue-bg:      #e3f2fd;

  /* Type */
  --yip-font-ui:      'Inter', system-ui, -apple-system, sans-serif;
  --yip-font-mono:    'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --yip-font-size:    13px;
  --yip-line-height:  1.5;
}

/* ── Reset / base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--yip-shell-bg);
  color: var(--yip-text);
  font-family: var(--yip-font-ui);
  font-size: var(--yip-font-size);
  line-height: var(--yip-line-height);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--yip-accent-dark); text-decoration: none; }
a:hover { color: var(--yip-accent); }

/* ── Shell layout ────────────────────────────────────────────────────────── */
.yip-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.yip-sidebar {
  width: var(--yip-sidebar-w);
  min-width: var(--yip-sidebar-w);
  background: var(--yip-sidebar-bg);
  border-right: 1px solid var(--yip-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  z-index: 100;
}

.yip-sidebar.collapsed {
  width: 0;
  min-width: 0;
}

/* Brand */
.yip-brand {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--yip-border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  white-space: nowrap;
  overflow: hidden;
  background: var(--yip-surface);
}

.yip-brand-logo {
  width: 100%;
  max-width: 160px;
  height: auto;
  display: block;
  object-fit: contain;
}

.yip-brand-name {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yip-text-dim);
  padding-left: 1px;
}

/* Nav */
.yip-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--yip-border) transparent;
}

.yip-nav-group {
  border-bottom: 1px solid var(--yip-border-light);
}

.yip-nav-group-btn {
  width: 100%;
  background: none;
  border: none;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--yip-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.yip-nav-group-btn:hover {
  color: var(--yip-text);
  background: rgba(0,0,0,0.04);
}

.yip-nav-group.open .yip-nav-group-btn {
  color: var(--yip-text);
}

.yip-nav-group-btn .bi:first-child {
  font-size: 13px;
  flex-shrink: 0;
}

.yip-nav-chevron {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s;
}

.yip-nav-group.open .yip-nav-chevron {
  transform: rotate(90deg);
}

.yip-nav-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  background: rgba(0,0,0,0.03);
}

.yip-nav-group.open .yip-nav-items {
  display: block;
}

.yip-nav-link {
  display: block;
  padding: 6px 12px 6px 34px;
  color: var(--yip-text-muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.yip-nav-link:hover {
  color: var(--yip-text);
  background: rgba(0,0,0,0.04);
}

.yip-nav-link.active {
  color: var(--yip-accent-dark);
  background: var(--yip-accent-glow);
  border-left: 2px solid var(--yip-accent);
  padding-left: 32px;
  font-weight: 600;
}

/* Sidebar footer */
.yip-sidebar-footer {
  border-top: 1px solid var(--yip-border);
  padding: 10px 12px;
  flex-shrink: 0;
  background: var(--yip-surface);
}

.yip-user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--yip-text);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.yip-user-info .bi {
  color: var(--yip-text-muted);
  flex-shrink: 0;
}

.yip-role-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 2px;
  background: var(--yip-accent-glow);
  color: var(--yip-accent-dark);
  flex-shrink: 0;
}

.yip-sidebar-actions {
  display: flex;
  gap: 4px;
}

.yip-footer-link {
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  color: var(--yip-text-muted);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s, background 0.15s;
  font-family: var(--yip-font-ui);
}

.yip-footer-link:hover {
  color: var(--yip-text);
  background: var(--yip-border-light);
}

/* ── Main area ───────────────────────────────────────────────────────────── */
.yip-main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.yip-topbar {
  height: var(--yip-topbar-h);
  min-height: var(--yip-topbar-h);
  background: var(--yip-surface);
  border-bottom: 1px solid var(--yip-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.yip-sidebar-toggle {
  background: none;
  border: none;
  color: var(--yip-text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.yip-sidebar-toggle:hover {
  color: var(--yip-text);
  background: var(--yip-shell-bg);
}

.yip-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.yip-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.yip-page-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--yip-text);
  margin: 0;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.yip-card {
  background: var(--yip-surface);
  border: 1px solid var(--yip-border);
  border-radius: 4px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.yip-card-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--yip-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--yip-surface-2);
}

.yip-card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yip-text-muted);
  margin: 0;
}

.yip-card-body { padding: 16px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.yip-table-wrap {
  overflow-x: auto;
  border-radius: 0 0 4px 4px;
}

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

.yip-table th {
  background: var(--yip-surface-2);
  color: var(--yip-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--yip-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.yip-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--yip-border-light);
  color: var(--yip-text);
  vertical-align: middle;
}

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

.yip-table tbody tr:hover { background: #f9fafb; }

.yip-table .mono {
  font-family: var(--yip-font-mono);
  font-size: 11px;
  color: var(--yip-accent-dark);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.yip-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.yip-field { display: flex; flex-direction: column; gap: 4px; }

.yip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--yip-text-muted);
}

.yip-input,
.yip-select,
.yip-textarea {
  background: var(--yip-surface);
  border: 1px solid var(--yip-border);
  border-radius: 3px;
  color: var(--yip-text);
  font-size: 12px;
  font-family: var(--yip-font-ui);
  padding: 6px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.yip-input:focus,
.yip-select:focus,
.yip-textarea:focus {
  outline: none;
  border-color: var(--yip-accent);
  box-shadow: 0 0 0 2px var(--yip-accent-glow);
}

.yip-textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.yip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--yip-font-ui);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.yip-btn-primary {
  background: var(--yip-accent);
  color: #ffffff;
  border-color: var(--yip-accent);
}
.yip-btn-primary:hover {
  background: var(--yip-accent-dark);
  border-color: var(--yip-accent-dark);
  color: #ffffff;
}

.yip-btn-secondary {
  background: var(--yip-surface);
  color: var(--yip-text);
  border-color: var(--yip-border);
}
.yip-btn-secondary:hover {
  background: var(--yip-surface-2);
  border-color: var(--yip-text-dim);
}

.yip-btn-danger {
  background: transparent;
  color: var(--yip-red);
  border-color: var(--yip-red);
}
.yip-btn-danger:hover { background: var(--yip-red-bg); }

.yip-btn-sm { padding: 3px 9px; font-size: 11px; }
.yip-btn-icon { padding: 5px 8px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.yip-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.yip-badge-green  { background: var(--yip-green-bg);  color: var(--yip-green); }
.yip-badge-red    { background: var(--yip-red-bg);    color: var(--yip-red); }
.yip-badge-yellow { background: var(--yip-yellow-bg); color: var(--yip-yellow); }
.yip-badge-blue   { background: var(--yip-blue-bg);   color: var(--yip-blue); }
.yip-badge-muted  { background: var(--yip-surface-2); color: var(--yip-text-muted);
                    border: 1px solid var(--yip-border); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.yip-alert {
  padding: 10px 14px;
  border-radius: 3px;
  font-size: 12px;
  border-left: 3px solid;
  margin-bottom: 14px;
}
.yip-alert-error   { background: var(--yip-red-bg);    border-color: var(--yip-red);    color: var(--yip-red); }
.yip-alert-success { background: var(--yip-green-bg);  border-color: var(--yip-green);  color: var(--yip-green); }
.yip-alert-warn    { background: var(--yip-yellow-bg); border-color: var(--yip-yellow); color: var(--yip-yellow); }
.yip-alert-info    { background: var(--yip-blue-bg);   border-color: var(--yip-blue);   color: var(--yip-blue); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#yip-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.yip-toast {
  background: var(--yip-surface);
  border: 1px solid var(--yip-border);
  border-left: 3px solid var(--yip-accent);
  border-radius: 3px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--yip-text);
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  animation: toast-in 0.2s ease;
  pointer-events: auto;
}

.yip-toast.success { border-left-color: var(--yip-green); }
.yip-toast.error   { border-left-color: var(--yip-red); }
.yip-toast.warning { border-left-color: var(--yip-yellow); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.yip-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  font-size: 12px;
}

.yip-page-btn {
  padding: 4px 9px;
  background: var(--yip-surface);
  border: 1px solid var(--yip-border);
  border-radius: 3px;
  color: var(--yip-text-muted);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--yip-font-ui);
  transition: all 0.15s;
}
.yip-page-btn:hover { color: var(--yip-text); border-color: var(--yip-text-dim); }
.yip-page-btn.active { background: var(--yip-accent); color: #fff; border-color: var(--yip-accent); }
.yip-page-btn:disabled { opacity: 0.35; cursor: default; }

.yip-page-info { color: var(--yip-text-muted); margin: 0 6px; }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.yip-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.yip-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.yip-search-wrap .bi {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--yip-text-dim);
  font-size: 13px;
  pointer-events: none;
}

.yip-search { padding-left: 30px; width: 100%; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.yip-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--yip-border);
  border-top-color: var(--yip-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.yip-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--yip-text-muted);
  font-size: 12px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.yip-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--yip-text-muted);
}
.yip-empty i { font-size: 32px; display: block; margin-bottom: 10px; opacity: 0.3; }
.yip-empty p { font-size: 13px; margin: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .yip-sidebar {
    position: fixed;
    height: 100vh;
    top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 200;
  }
  .yip-sidebar.mobile-open { transform: translateX(0); }
  .yip-main-wrap { width: 100%; }
  .yip-content { padding: 14px 16px; }
}

/* ── Bootstrap overrides ─────────────────────────────────────────────────── */
.form-control, .form-select {
  background-color: var(--yip-surface);
  border-color: var(--yip-border);
  color: var(--yip-text);
  font-size: 12px;
}
.form-control:focus, .form-select:focus {
  background-color: var(--yip-surface);
  border-color: var(--yip-accent);
  color: var(--yip-text);
  box-shadow: 0 0 0 2px var(--yip-accent-glow);
}
.modal-content {
  background: var(--yip-surface);
  border: 1px solid var(--yip-border);
  color: var(--yip-text);
}
.modal-header, .modal-footer { border-color: var(--yip-border-light); }
