/* C&A CRM - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --white:       #ffffff;
  --bg:          #f5f7fa;
  --bg-card:     #ffffff;
  --border:      #e2e8f0;
  --border-light:#f0f4f8;

  --green-50:    #f0faf4;
  --green-100:   #dcf5e7;
  --green-500:   #22a45d;
  --green-600:   #1a8f4f;
  --green-700:   #166f3e;
  --green-800:   #115530;

  --text-dark:   #0f172a;
  --text-body:   #334155;
  --text-muted:  #64748b;
  --text-light:  #94a3b8;

  --sidebar-bg:  #0f172a;
  --sidebar-w:   240px;

  --danger:      #ef4444;
  --danger-bg:   #fef2f2;
  --warning:     #f59e0b;
  --warning-bg:  #fffbeb;
  --info:        #3b82f6;
  --info-bg:     #eff6ff;
  --success:     #22a45d;
  --success-bg:  #f0faf4;

  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.12);

  --font-heading: 'Outfit', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --transition:  .18s ease;
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-body);
  min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-family: var(--font-heading); color: var(--text-dark); font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p  { line-height: 1.6; }
a  { color: var(--green-600); text-decoration: none; }
a:hover { color: var(--green-700); }

/* ── Layout ──────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.brand-ca {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
  color: #ffffff;
  letter-spacing: .02em;
}

.brand-crm {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: .8rem;
  color: rgba(255,255,255,.45);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
  border-left-color: rgba(255,255,255,.2);
}

.nav-item.active {
  color: #fff;
  background: rgba(34,164,93,.18);
  border-left-color: var(--green-500);
}

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

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--green-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,.4); }

.btn-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
  display: flex;
}
.btn-logout:hover { color: var(--danger); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title-bar h1 { font-size: 1.1rem; font-weight: 700; color: var(--text-dark); }
.page-title-bar p  { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }

.top-bar-actions { display: flex; align-items: center; gap: 10px; }

.page-body {
  padding: 28px;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 12px;
}
.stat-icon.green  { background: var(--green-100); color: var(--green-600); }
.stat-icon.blue   { background: #dbeafe; color: var(--info); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red    { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-value { font-family: var(--font-heading); font-size: 1.7rem; font-weight: 700; color: var(--text-dark); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: .85rem;
  font-weight: 600;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green-600);
  color: #fff;
}
.btn-primary:hover { background: var(--green-700); color: #fff; }

.btn-secondary {
  background: var(--white);
  color: var(--text-body);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-icon { padding: 7px; border-radius: 8px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); }

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

thead th {
  background: var(--sidebar-bg);
  color: rgba(255,255,255,.85);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: .78rem;
  letter-spacing: .03em;
  padding: 11px 16px;
  text-align: left;
  white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

tbody tr { border-bottom: 1px solid var(--border-light); transition: var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--green-50); }

tbody td { padding: 11px 16px; color: var(--text-body); vertical-align: middle; }

.td-actions { display: flex; gap: 6px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-dark); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  font-size: .88rem;
  font-family: var(--font-body);
  color: var(--text-dark);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(34,164,93,.12); }
.form-control::placeholder { color: var(--text-light); }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

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

.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: .02em;
}
.badge-green   { background: var(--green-100); color: var(--green-700); }
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-orange  { background: #fef3c7; color: #92400e; }
.badge-red     { background: var(--danger-bg); color: #b91c1c; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
.modal-overlay.hidden { display: none; }

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

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
.modal-lg { max-width: 780px; }

.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text-dark); }

.modal-body  { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-light); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Alert ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--success-bg); color: var(--green-700); border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-bg);  color: #b91c1c;          border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e;          border: 1px solid #fde68a; }
.alert-info    { background: var(--info-bg);    color: #1d4ed8;          border: 1px solid #bfdbfe; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .84rem;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--green-700); }
.toast.error   { background: var(--danger); }

/* ── Filters Bar ─────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters-bar .form-control { width: auto; min-width: 180px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 1rem; color: var(--text-body); margin-bottom: 6px; }
.empty-state p  { font-size: .85rem; }

/* ── Package Summary Bar ─────────────────────────────────── */
.pkg-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.pkg-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.pkg-stat.highlight { border-color: var(--green-500); background: var(--green-50); }
.pkg-stat .val { font-family: var(--font-heading); font-size: 1.4rem; font-weight: 700; color: var(--text-dark); }
.pkg-stat.highlight .val { color: var(--green-600); }
.pkg-stat .lbl { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Progress Bar ─────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--green-500); border-radius: 10px; transition: width .4s ease; }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Print / PDF ─────────────────────────────────────────── */
@media print {
  .sidebar, .top-bar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .page-body { padding: 0; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .main-content { margin-left: 0; }
}
