/* Primark Carton Supply Report - PACD Theme (reference: Carton Price Calculator) */
:root {
  --primary: #00205b;
  --primary-hover: #001540;
  --secondary: #e31837;
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-decoration {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(circle at 10% 10%, rgba(227, 24, 55, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(0, 32, 91, 0.03) 0%, transparent 40%);
  z-index: -1;
  pointer-events: none;
}

.navbar {
  height: 70px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-img { height: 40px; width: auto; object-fit: contain; }

.navbar h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--primary);
}

.primark-logo { height: 30px; width: auto; object-fit: contain; }

.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 80px;
}

.calculator-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 2.5rem;
  max-width: 1400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-section { margin-bottom: 1.5rem; }

.section-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.form-group { margin-bottom: 0; position: relative; }

.select-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 500;
}

.custom-select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.custom-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 32, 91, 0.1);
}

.filter-widget { position: relative; }

.filter-trigger {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 2.5rem 0.75rem 0.75rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
}

.filter-trigger:focus,
.filter-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 32, 91, 0.1);
}

.filter-summary {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  padding: 0.25rem 0;
}

.filter-search {
  position: sticky;
  top: 0;
  width: calc(100% - 1rem);
  margin: 0.25rem 0.5rem 0.4rem;
  padding: 0.5rem 0.65rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.filter-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 32, 91, 0.1);
}

.filter-all {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.filter-all:hover { background: rgba(0, 32, 91, 0.05); }

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.filter-option:hover { background: rgba(0, 32, 91, 0.05); }

.filter-all input,
.filter-option input { accent-color: var(--primary); cursor: pointer; }

.export-area {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0 1.5rem;
  height: 50px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0, 32, 91, 0.2);
  font-family: inherit;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 32, 91, 0.25);
}

.primary-btn:disabled {
  background: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.row-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

#table {
  max-height: 500px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#table table { width: 100%; border-collapse: collapse; }

#table thead { position: sticky; top: 0; z-index: 1; }

#table th {
  background: var(--primary);
  color: #ffffff;
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

#table th:nth-child(-n+4) { text-align: left; }

#table td {
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

#table td:nth-child(-n+4) { text-align: left; }

#table td:nth-child(n+5) { font-weight: 600; color: var(--primary); }

#table tbody tr { transition: background-color 0.15s; }
#table tbody tr:hover { background-color: #eff6ff; }

#table p {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
  font-style: italic;
}

.error-box {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #8b1e1e;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

#export-error:empty, #data-error:empty { display: none; }

.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 2rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: inherit;
}

.app-footer .divider { opacity: 0.5; margin: 0 0.5rem; }

.app-footer .developer-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
}

.app-footer .developer-link:hover { opacity: 0.8; text-decoration: underline; }

@media (max-width: 640px) {
  .navbar { padding: 0 0.75rem; gap: 0.5rem; }
  .navbar h1 { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .logo-img { height: 22px; }
  .primark-logo { height: 16px; }
  .main-container { padding: 20px 1rem 80px; }
  .calculator-card { padding: 1.5rem; }
  .filter-grid { grid-template-columns: 1fr; }
}
