/* ============================================================
   BizManager Pro - Main Stylesheet
   Responsive Design for all devices
   ============================================================ */

:root {
  --primary:       #1a56db;
  --primary-dark:  #1e429f;
  --primary-light: #e8f0fe;
  --secondary:     #6b7280;
  --success:       #057a55;
  --danger:        #c81e1e;
  --warning:       #c27803;
  --info:          #0694a2;
  --dark:          #111827;
  --light:         #f9fafb;
  --white:         #ffffff;
  --border:        #e5e7eb;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.1);
  --shadow:        0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.15);
  --radius:        10px;
  --radius-lg:     16px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w:     260px;
  --topbar-h:      65px;
  --transition:    all .25s ease;
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 15px; }
body { font-family: var(--font); background: #f0f2f7; color: var(--dark); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
input, select, textarea, button { font-family: inherit; }
.hidden { display: none !important; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* ══════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════ */

/* Sidebar Layout */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--dark);
  display: flex; flex-direction: column;
  z-index: 1000; transition: var(--transition);
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}
.sidebar-brand .brand-icon {
  width: 38px; height: 38px; background: var(--primary);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 1.2rem; color: #fff; flex-shrink: 0;
}
.sidebar-brand .brand-text { color: #fff; font-size: .95rem; font-weight: 700; line-height: 1.2; }
.sidebar-brand .brand-sub  { color: rgba(255,255,255,.45); font-size: .7rem; }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section { padding: .5rem 1.5rem .25rem; font-size: .65rem; font-weight: 700;
               letter-spacing: .1em; color: rgba(255,255,255,.3); text-transform: uppercase; }

.nav-item { margin: 1px 0; }
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.5rem; color: rgba(255,255,255,.65);
  font-size: .875rem; font-weight: 500; border-radius: 0;
  transition: var(--transition); position: relative;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-link.active { color: #fff; background: var(--primary);
  box-shadow: inset 3px 0 0 rgba(255,255,255,.5); }
.nav-link i { font-size: 1rem; width: 1.25rem; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .65rem; padding: 2px 6px; border-radius: 20px; font-weight: 700;
}
.sidebar-footer {
  padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem; color: rgba(255,255,255,.4);
}

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

/* ── Top Bar ────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 900;
  background: var(--white); border-bottom: 1px solid var(--border);
  height: var(--topbar-h); display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem; box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; flex: 1; }
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--dark); }
.topbar-breadcrumb { font-size: .8rem; color: var(--secondary); }

.topbar-right { display: flex; align-items: center; gap: .5rem; }
.topbar-btn {
  width: 38px; height: 38px; border: none; background: none;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--secondary); cursor: pointer;
  position: relative; transition: var(--transition);
}
.topbar-btn:hover { background: var(--light); color: var(--primary); }
.notif-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid #fff;
}
.user-avatar-sm {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--border);
}

/* ── Page Content ───────────────────────────────────────── */
.page-content { padding: 1.5rem; flex: 1; }
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--dark); }
.page-subtitle { color: var(--secondary); font-size: .875rem; margin-top: .15rem; }

/* ══════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════ */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white);
}
.card-title { font-size: .95rem; font-weight: 700; color: var(--dark); }
.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 1.25rem; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; margin-bottom: .75rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--dark); line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--secondary); margin-top: .25rem; }
.stat-card .stat-change { font-size: .75rem; font-weight: 600; margin-top: .5rem; }
.stat-card .stat-change.up   { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger);  }
.stat-card .stat-bg {
  position: absolute; right: -10px; bottom: -10px;
  font-size: 5rem; opacity: .05; line-height: 1;
}

/* Color variants */
.bg-primary-soft { background: var(--primary-light); color: var(--primary); }
.bg-success-soft { background: #def7ec; color: var(--success); }
.bg-danger-soft  { background: #fde8e8; color: var(--danger); }
.bg-warning-soft { background: #fdf6b2; color: var(--warning); }
.bg-info-soft    { background: #e0f2f2; color: var(--info); }
.bg-purple-soft  { background: #edebfe; color: #6c2bd9; }

/* ══════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════ */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
table th {
  background: var(--light); padding: .75rem 1rem;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--secondary);
  border-bottom: 2px solid var(--border); white-space: nowrap; text-align: left;
}
table td {
  padding: .7rem 1rem; border-bottom: 1px solid var(--border);
  font-size: .875rem; color: var(--dark); vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #fafafa; }

/* ══════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--dark); margin-bottom: .4rem; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control, .form-select {
  width: 100%; padding: .55rem .9rem; font-size: .875rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--white); color: var(--dark);
  transition: var(--transition); outline: none; appearance: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: .78rem; color: var(--danger); margin-top: .25rem; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.form-check-input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; font-size: .875rem; font-weight: 600;
  border: none; border-radius: 8px; cursor: pointer;
  transition: var(--transition); white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover   { background: var(--primary-dark); color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover   { background: #046c4e; color: #fff; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover    { background: #9b1c1c; color: #fff; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-info      { background: var(--info);      color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-light     { background: var(--light); color: var(--dark); border: 1px solid var(--border); }
.btn-light:hover     { background: var(--border); }
.btn-outline-primary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-sm   { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg   { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: .2rem .6rem;
  font-size: .7rem; font-weight: 700; border-radius: 20px; letter-spacing: .03em;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #def7ec; color: var(--success); }
.badge-danger  { background: #fde8e8; color: var(--danger); }
.badge-warning { background: #fdf6b2; color: var(--warning); }
.badge-info    { background: #e0f2f2; color: var(--info); }
.badge-secondary { background: #f3f4f6; color: var(--secondary); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: .85rem 1rem; border-radius: var(--radius);
  border-left: 4px solid transparent; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .6rem; font-size: .875rem;
}
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-danger  { background: #fff1f2; border-color: var(--danger);  color: #9f1239; }
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #92400e; }
.alert-info    { background: #f0f9ff; border-color: var(--info);    color: #075985; }
.alert-dismissible { position: relative; }
.btn-close { background: none; border: none; cursor: pointer; margin-left: auto; opacity: .5; font-size: 1.1rem; }
.btn-close:hover { opacity: 1; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(.95); transition: transform .2s;
}
.modal-overlay.active .modal-box { transform: scale(1); }
.modal-header {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body   { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .75rem;
}

/* ══════════════════════════════════════════════════════════
   GUEST / PUBLIC PAGES
   ══════════════════════════════════════════════════════════ */
.public-nav {
  position: sticky; top: 0; z-index: 999;
  background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.public-nav .container {
  max-width: 1200px; margin: auto; padding: 0 1.5rem;
  display: flex; align-items: center; height: 65px; gap: 2rem;
}
.pub-nav-links { display: flex; gap: .25rem; flex: 1; }
.pub-nav-link {
  padding: .5rem .9rem; border-radius: 7px; font-size: .875rem;
  font-weight: 500; color: var(--secondary); transition: var(--transition);
}
.pub-nav-link:hover, .pub-nav-link.active { color: var(--primary); background: var(--primary-light); }
.pub-nav-actions { display: flex; gap: .5rem; }

.hero-section {
  background: linear-gradient(135deg, #1a56db 0%, #1e429f 50%, #1d4ed8 100%);
  color: #fff; padding: 5rem 1.5rem; text-align: center; position: relative; overflow: hidden;
}
.hero-section::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-section .container { max-width: 800px; margin: auto; position: relative; }
.hero-title { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.15; margin-bottom: 1rem; }
.hero-sub { font-size: 1.1rem; opacity: .85; margin-bottom: 2rem; max-width: 580px; margin-left: auto; margin-right: auto; }

.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.25rem; }
.service-card {
  background: var(--white); border-radius: var(--radius); padding: 1.5rem;
  border: 1px solid var(--border); text-align: center; transition: var(--transition);
  cursor: pointer;
}
.service-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); border-color: var(--primary); }
.service-card .svc-icon {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center; font-size: 1.75rem;
}
.service-card .svc-name { font-size: .95rem; font-weight: 700; margin-bottom: .35rem; }
.service-card .svc-desc { font-size: .8rem; color: var(--secondary); }

/* ══════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a56db 0%, #1e429f 100%); padding: 1.5rem;
}
.auth-card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; overflow: hidden;
}
.auth-header {
  background: var(--dark); padding: 2rem 2rem 1.5rem; text-align: center;
}
.auth-logo { color: #fff; font-size: 1.5rem; font-weight: 800; }
.auth-tagline { color: rgba(255,255,255,.5); font-size: .8rem; margin-top: .25rem; }
.auth-body { padding: 2rem; }
.auth-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--dark); }

/* ══════════════════════════════════════════════════════════
   MESSAGING
   ══════════════════════════════════════════════════════════ */
.msg-list { display: flex; flex-direction: column; gap: .4rem; }
.msg-item {
  display: flex; gap: .75rem; padding: .85rem 1rem;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
  transition: var(--transition); align-items: flex-start;
}
.msg-item:hover { background: var(--light); }
.msg-item.unread { background: var(--primary-light); border-color: rgba(26,86,219,.2); }
.msg-item.unread .msg-subject { font-weight: 700; }
.msg-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex;
  align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: .9rem;
}
.msg-sender  { font-weight: 600; font-size: .875rem; }
.msg-subject { font-size: .8rem; color: var(--dark); }
.msg-preview { font-size: .78rem; color: var(--secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-time    { font-size: .72rem; color: var(--secondary); white-space: nowrap; margin-left: auto; }

/* Message Bubble (full view) */
.msg-bubble {
  max-width: 80%; padding: .85rem 1rem;
  border-radius: 14px; font-size: .875rem; line-height: 1.55; position: relative;
}
.msg-bubble.sent { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; margin-left: auto; }
.msg-bubble.recv { background: var(--light); color: var(--dark); border-bottom-left-radius: 4px; }

/* ══════════════════════════════════════════════════════════
   CHARTS PLACEHOLDER
   ══════════════════════════════════════════════════════════ */
.chart-container { position: relative; width: 100%; }

/* ══════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════ */
.d-flex          { display: flex; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: 1rem; } .mb-4 { margin-bottom: 1.5rem; }
.p-0 { padding: 0; } .text-center { text-align: center; } .text-right { text-align: right; }
.text-muted { color: var(--secondary); font-size: .85rem; }
.text-small { font-size: .8rem; }
.fw-bold { font-weight: 700; } .fw-600 { font-weight: 600; }
.text-primary { color: var(--primary); } .text-success { color: var(--success); }
.text-danger   { color: var(--danger);  } .text-warning { color: var(--warning); }
.w-100 { width: 100%; }
.rounded-full { border-radius: 50%; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  background: var(--primary); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.spinner {
  display: inline-block; width: 1rem; height: 1rem;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-260px); width: 260px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .services-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 1rem; }
  .page-content { padding: 1rem; }
  .hero-section { padding: 3rem 1.5rem; }
  .pub-nav-links { display: none; }
  .sidebar-toggle { display: flex !important; }
  .modal-box { max-width: 100%; margin: 0 .5rem; }
  table th, table td { padding: .6rem .75rem; font-size: .8rem; }
}
@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
  .services-grid { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: 1.4rem; }
}

/* ── Sidebar Toggle Button (mobile) ─────────────────────── */
.sidebar-toggle {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: var(--dark); padding: .25rem;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* Print */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: #fff; }
}
