/* =====================================================================
   Pharma Distribution Manager — stylesheet
   Fully self-contained (no external fonts/CDNs) for offline XAMPP use.
   ===================================================================== */

:root {
  --color-primary: #145c54;
  --color-primary-dark: #0d3f3a;
  --color-primary-light: #e4f2f0;
  --color-accent: #2f8f7a;
  --color-danger: #b3261e;
  --color-danger-light: #fbe9e7;
  --color-warning: #a15c00;
  --color-warning-light: #fff2df;
  --color-success: #1e7a4c;
  --color-success-light: #e6f6ee;
  --color-bg: #f5f7f7;
  --color-surface: #ffffff;
  --color-border: #dfe6e4;
  --color-text: #1f2b29;
  --color-text-muted: #5b6b68;
  --sidebar-width: 240px;
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; color: var(--color-primary-dark); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

/* ---------------------------------------------------------------- */
/* Layout                                                            */
/* ---------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-primary-dark);
  color: #dff2ee;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform .2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-weight: 700;
  color: #fff;
  font-size: 1.05rem;
}

.sidebar-brand .mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; font-weight: 700; color: #06231f;
}

.sidebar nav { padding: .75rem 0; }

.sidebar .section-label {
  text-transform: none;
  font-size: .72rem;
  color: #8fbdb4;
  padding: .9rem 1.2rem .3rem;
}

.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.2rem;
  color: #cfe9e3;
  font-size: .92rem;
  border-left: 3px solid transparent;
}

.sidebar a.nav-link:hover {
  background: rgba(255,255,255,.06);
  text-decoration: none;
}

.sidebar a.nav-link.active {
  background: rgba(47,143,122,.25);
  border-left-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
}

.icon { width: 18px; text-align: center; flex-shrink: 0; }

.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .page-title { font-size: 1.1rem; font-weight: 600; margin: 0; }

.topbar-user { display: flex; align-items: center; gap: .9rem; font-size: .9rem; color: var(--color-text-muted); }

.menu-toggle {
  display: none;
  background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--color-primary-dark);
}

.content { padding: 1.5rem; flex: 1; }

.overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 39;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; width: 100%; }
  .menu-toggle { display: inline-block; }
  .overlay.show { display: block; }
}

/* ---------------------------------------------------------------- */
/* Cards / panels                                                    */
/* ---------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: .75rem;
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.stat-card .label { font-size: .8rem; color: var(--color-text-muted); margin-bottom: .3rem; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; color: var(--color-primary-dark); }
.stat-card.warning { border-left-color: var(--color-warning); }
.stat-card.danger { border-left-color: var(--color-danger); }
.stat-card.success { border-left-color: var(--color-success); }

/* ---------------------------------------------------------------- */
/* Tables                                                            */
/* ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

table.data-table th, table.data-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

table.data-table th {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 600;
  position: sticky;
  top: 0;
}

table.data-table tbody tr:hover { background: #fafcfb; }
table.data-table td.wrap { white-space: normal; }
table.data-table td.num, table.data-table th.num { text-align: right; }

.row-expiring { background: var(--color-warning-light) !important; }
.row-expired { background: var(--color-danger-light) !important; }

/* ---------------------------------------------------------------- */
/* Forms                                                             */
/* ---------------------------------------------------------------- */

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

.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--color-text); }
.form-group .hint { font-size: .78rem; color: var(--color-text-muted); }

input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=tel], input[type=search], select, textarea {
  padding: .55rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(47,143,122,.15);
}

textarea { resize: vertical; min-height: 70px; }

.form-actions { display: flex; gap: .6rem; margin-top: 1rem; }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--color-primary);
  color: #fff;
  line-height: 1.2;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-secondary { background: #fff; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: #f1f4f3; color: var(--color-text); }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #8f1e18; }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary-light); color: var(--color-primary); }

/* Badges */

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  background: #eef1f0;
  color: var(--color-text-muted);
}
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-light); color: var(--color-danger); }
.badge-muted   { background: #eef1f0; color: var(--color-text-muted); }

/* Alerts / flash messages */

.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .9rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--color-success-light); color: var(--color-success); border-color: #bfe6cf; }
.alert-danger  { background: var(--color-danger-light); color: var(--color-danger); border-color: #f0c6c2; }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning); border-color: #f2ddb0; }
.alert-info    { background: var(--color-primary-light); color: var(--color-primary-dark); border-color: #bfe0da; }

/* Login page */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-primary-dark), var(--color-primary) 60%, var(--color-accent));
  padding: 1rem;
}

.login-card {
  background: #fff;
  width: 100%;
  max-width: 380px;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

.login-card h1 { text-align: center; margin-bottom: .2rem; }
.login-card p.sub { text-align: center; color: var(--color-text-muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login-card .btn { width: 100%; justify-content: center; margin-top: .5rem; }

/* Misc utility */

.text-muted { color: var(--color-text-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: .5rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filters .form-group { margin-bottom: 0; min-width: 160px; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-muted); }
.pill-group { display: flex; gap: .4rem; flex-wrap: wrap; }
.tag-line { font-size: .8rem; color: var(--color-text-muted); }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-area { margin-left: 0 !important; width: 100% !important; }
  body { background: #fff; }
}
