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

:root {
  --primary: #2E5FA3;         /* main blue — buttons, active states */
  --primary-dark: #1F3864;    /* dark blue — header, sidebar */
  --accent: #ED7D31;          /* orange — highlights, CTAs */
  --accent-light: #FCE4D6;    /* light orange — selling price highlight */
  --success: #375623;         /* dark green — profit values */
  --success-bg: #E2EFDA;      /* light green — profit cell bg */
  --warning: #C00000;         /* red — break-even values if needed */
  --input-bg: #FFF2CC;        /* yellow — user-editable inputs (admin) */
  --auto-bg: #E2EFDA;         /* green — auto-calculated values */
  --row-alt: #D9E1F2;         /* light blue — alternating rows */
  --border: #BFBFBF;
  --text-primary: #1a1a1a;
  --text-secondary: #595959;
  --bg-page: #f5f5f5;
  --bg-card: #ffffff;
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--primary-dark);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  background-color: var(--primary-dark);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  color: white;
  font-size: 1.5rem;
  margin: 0;
}

header p {
  color: #ccc;
  font-size: 0.9rem;
}

header .header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Buttons */
.btn {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}

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

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

.btn-primary:hover {
  background-color: #244b80;
}

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

.btn-accent:hover {
  background-color: #d86c24;
}

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

.btn-danger:hover {
  background-color: #a00000;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background-color: #eee;
}

.btn-block {
  width: 100%;
  display: block;
}

.btn-large {
  padding: 15px 30px;
  font-size: 1.1rem;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Forms */
.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  min-height: 44px;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(46, 95, 163, 0.2);
}

.input-editable {
  background-color: var(--input-bg);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  margin-bottom: 20px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-card);
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

th {
  background-color: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;
}

tbody tr:nth-of-type(even) {
  background-color: var(--row-alt);
}

tbody tr:hover {
  background-color: #f1f4fb;
}

.price-highlight {
  background-color: var(--accent-light) !important;
  font-weight: 700;
  color: #a34e0d;
}

.profit-highlight {
  color: var(--success);
  font-weight: 600;
}

/* Utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--warning); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-secondary); font-size: 0.9rem; }

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.ml-1 { margin-left: 10px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.space-between { justify-content: space-between; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }
.hidden { display: none !important; }

/* Grid Layouts - Admin */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background-color: var(--primary-dark);
  color: white;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar a {
  display: block;
  color: #ccc;
  text-decoration: none;
  padding: 12px 20px;
  border-left: 4px solid transparent;
  transition: all 0.2s;
}

.sidebar a:hover, .sidebar a.active {
  color: white;
  background-color: rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent);
}

.admin-main {
  flex-grow: 1;
  background-color: var(--bg-page);
  display: flex;
  flex-direction: column;
}

.admin-content {
  padding: 20px;
  flex-grow: 1;
  overflow-y: auto;
}

/* Admin Sections */
.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}

/* Toasts */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

.toast {
  background-color: var(--success);
  color: white;
  padding: 15px 25px;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(120%);
  animation: slideIn 0.3s forwards;
}

.toast.toast-error {
  background-color: var(--warning);
}

.toast.hiding {
  animation: slideOut 0.3s forwards;
}

@keyframes slideIn {
  to { transform: translateX(0); }
}

@keyframes slideOut {
  to { transform: translateX(120%); }
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9000;
  backdrop-filter: blur(3px);
}

.modal {
  background-color: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Login Shake */
.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.inline-error {
  color: var(--warning);
  font-size: 0.85em;
  margin-top: 5px;
  display: none;
}

/* Mobile responsive cards for tables */
@media (max-width: 600px) {
  table.responsive-cards thead {
    display: none;
  }
  table.responsive-cards tbody {
    display: block;
    width: 100%;
  }
  table.responsive-cards tr {
    display: block;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    background-color: var(--bg-card) !important;
  }
  table.responsive-cards td {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
    padding: 10px 15px;
  }
  table.responsive-cards td:last-child {
    border-bottom: none;
  }
  table.responsive-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 15px;
  }
}

/* Print styles */
@media print {
  header, .print-hide, .btn, .sidebar {
    display: none !important;
  }
  .admin-layout, .container, body {
    background-color: white !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: auto !important;
  }
  .card, table, .table-responsive {
    box-shadow: none !important;
    border: none !important;
  }
  table {
    border-collapse: collapse !important;
  }
  th, td {
    border: 1px solid #ccc !important;
  }
}
