/* ============================================
   LEGALMITRA LAWYER PANEL — MAIN STYLESHEET
   Version: 1.0 | Based on UI Spec Document
   ============================================ */

/* ---- DESIGN TOKENS (from spec) ---- */
:root {
  --sidebar-bg:          #FFFFFF;
  --sidebar-active-bg:   #1A1A1A;
  --sidebar-active-text: #FFFFFF;
  --sidebar-text:        #1A1A1A;
  --sidebar-subtext:     #555555;
  --sidebar-border:      #E8E0D5;
  --sidebar-width:       210px;

  --gold-primary:        #B8860B;
  --gold-light:          #D4A843;
  --gold-bg:             #FDF8EE;

  --page-bg:             #F9F6F1;
  --card-bg:             #FFFFFF;
  --card-border:         #EDE8DF;

  --success:             #43A047;
  --danger:              #E53935;
  --info:                #1E88E5;
  --warning:             #FB8C00;

  --text-primary:        #1A1A1A;
  --text-secondary:      #555555;
  --text-muted:          #888888;
  --online-dot:          #00C853;
}

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Poppins', system-ui, sans-serif;
  background-color: var(--page-bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { text-decoration: none; }

/* ============================================
   LAYOUT
   ============================================ */
.lm-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.lm-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: left 0.3s ease;
}

/* Sidebar scrollbar thin */
.lm-sidebar::-webkit-scrollbar { width: 4px; }
.lm-sidebar::-webkit-scrollbar-track { background: transparent; }
.lm-sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }

/* ---- Logo ---- */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 56px;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--gold-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.logo-law  { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.logo-lab  { font-size: 20px; font-weight: 700; color: var(--gold-primary); }

/* ---- Nav ---- */
.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 16px 12px 6px 12px;
  display: block;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-link-item i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.nav-link-item:hover {
  background: #F5F0E8;
  color: var(--text-primary);
}

.nav-link-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

/* Settings expandable */
.nav-link-item .chevron {
  margin-left: auto;
  font-size: 11px;
  transition: transform 0.2s;
}
.nav-link-item.expanded .chevron { transform: rotate(180deg); }

.nav-submenu { display: none; }
.nav-submenu.show { display: block; }

.nav-submenu .nav-link-item {
  padding-left: 40px;
  font-size: 12px;
}

/* ---- Logout ---- */
.sidebar-logout {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-logout:hover { background: #C62828; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.lm-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================
   TOP BAR
   ============================================ */
.lm-topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  height: 74px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-greeting {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-date {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.btn-topbar-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s;
}
.btn-topbar-icon:hover { background: #F5F0E8; }

/* Hamburger — mobile only */
.btn-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
}

/* ============================================
   CONTENT AREA
   ============================================ */
.lm-content {
  flex: 1;
  padding: 24px;
  background: var(--page-bg);
}

/* Page title */
.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ============================================
   STAT CARDS
   ============================================ */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.stat-card:hover {
  box-shadow: 0 4px 16px rgba(184,134,11,0.12);
  transform: translateY(-2px);
}

.stat-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  background: var(--gold-bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-primary);
  font-size: 16px;
}

.stat-card-arrow {
  width: 22px;
  height: 22px;
  border: 1px solid #CCCCCC;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}

.stat-card-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ============================================
   CARDS (general)
   ============================================ */
.lm-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
}

.lm-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lm-card-body { padding: 24px; }

/* Section dot + label */
.section-label-group { display: flex; align-items: center; gap: 8px; }

.section-dot {
  width: 8px;
  height: 8px;
  background: var(--gold-light);
  border-radius: 50%;
  flex-shrink: 0;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
}

/* ============================================
   UPGRADE PLAN BUTTON
   ============================================ */
.btn-upgrade {
  border: 1.5px solid var(--gold-primary);
  background: transparent;
  color: var(--gold-primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-upgrade:hover { background: var(--gold-bg); }

/* ============================================
   FEATURES LIST
   ============================================ */
.features-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  padding: 5px 0;
}

.feature-item i { color: var(--success); font-size: 14px; }

.empty-state {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   PROGRESS BARS (Usage Overview)
   ============================================ */
.usage-item { margin-bottom: 20px; }
.usage-item:last-child { margin-bottom: 0; }

.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.usage-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.usage-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.usage-sublabel {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

.lm-progress {
  height: 6px;
  background: #E8E0D5;
  border-radius: 3px;
  overflow: hidden;
}

.lm-progress-bar {
  height: 100%;
  background: var(--gold-light);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ============================================
   EXPIRY INFO ROW
   ============================================ */
.expiry-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: var(--gold-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 20px;
}

.expiry-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.expiry-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   PERFORMANCE CHARTS
   ============================================ */
.charts-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.charts-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.charts-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.toggle-group {
  display: flex;
  border: 1px solid #CCCCCC;
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.chart-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 20px;
}

.chart-box-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-area {
  height: 220px;
  background: #F8F8F8;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--card-border);
}

/* ============================================
   TABLES
   ============================================ */
.lm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lm-table thead th {
  background: var(--gold-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.lm-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  vertical-align: middle;
}

.lm-table tbody tr:last-child td { border-bottom: none; }

.lm-table tbody tr:hover { background: #FAFAF8; }

/* ============================================
   BADGES / STATUS
   ============================================ */
.badge-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success  { background: #E8F5E9; color: var(--success); }
.badge-warning  { background: #FFF8E1; color: #F57F17; }
.badge-danger   { background: #FFEBEE; color: var(--danger); }
.badge-info     { background: #E3F2FD; color: var(--info); }
.badge-pending  { background: #FFF3E0; color: var(--warning); }

/* ============================================
   BUTTONS
   ============================================ */
.btn-gold {
  background: var(--gold-primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-gold:hover { background: #9d7109; }

.btn-outline-gold {
  background: transparent;
  color: var(--gold-primary);
  border: 1.5px solid var(--gold-primary);
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-outline-gold:hover { background: var(--gold-bg); }

.btn-sm-action {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-sm-action:hover { background: var(--gold-bg); border-color: var(--gold-primary); color: var(--gold-primary); }

/* ============================================
   FORMS
   ============================================ */
.lm-form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: block;
}

.lm-form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color 0.15s;
  outline: none;
}

.lm-form-control:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px rgba(184,134,11,0.1);
}

.lm-form-control::placeholder { color: var(--text-muted); }

textarea.lm-form-control { resize: vertical; min-height: 100px; }

.form-group { margin-bottom: 18px; }

/* ============================================
   LIVE CHAT WIDGET
   ============================================ */
.chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  width: 300px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
}

.chat-widget-header {
  background: var(--sidebar-active-bg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-widget-title { font-size: 14px; font-weight: 600; color: #fff; }

.chat-online {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #A5D6A7;
}

.online-dot {
  width: 7px;
  height: 7px;
  background: var(--online-dot);
  border-radius: 50%;
}

.chat-widget-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
}
.chat-widget-close:hover { opacity: 1; }

.chat-widget-body {
  padding: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 60px;
}

/* ============================================
   SIDEBAR OVERLAY (mobile)
   ============================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}

.sidebar-overlay.show { display: block; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 991.98px) {
  .lm-sidebar {
    left: calc(-1 * var(--sidebar-width));
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
  }

  .lm-sidebar.open { left: 0; }

  .lm-main { margin-left: 0; }

  .btn-hamburger { display: flex; align-items: center; }
}

@media (max-width: 767.98px) {
  .lm-content { padding: 16px; }

  .lm-topbar { padding: 0 16px; }

  .stat-card-value { font-size: 22px; }

  .section-title { font-size: 18px; }

  /* ---- Table overflow fix ---- */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .lm-table {
    font-size: 12px;
    min-width: 560px; /* forces scroll instead of squish */
  }

  .lm-table thead th,
  .lm-table tbody td { padding: 10px 12px; }

  .charts-header { flex-direction: column; align-items: flex-start; }

  .chat-widget { width: calc(100vw - 32px); right: 16px; }

  /* ---- Chat layout fix ---- */
  .chat-layout {
    flex-direction: column;
    height: auto;
    overflow: hidden;
  }

  .chat-contacts {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    overflow-y: auto;
  }

  .chat-window {
    height: 400px;
  }

  /* ---- General overflow guard ---- */
  .lm-main,
  .lm-content,
  .lm-card,
  .lm-card-body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* ---- Expiry row stack on mobile ---- */
  .expiry-row {
    grid-template-columns: 1fr;
  }

  /* ---- Plan cards stack ---- */
  .plan-card { margin-bottom: 8px; }

  /* ---- Stat cards 2 col on small ---- */
  .stat-card-value { font-size: 20px; }
}

/* ============================================
   LOGOUT POPUP
   ============================================ */
.logout-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9998;
  align-items: center;
  justify-content: center;
}

.logout-overlay.show {
  display: flex;
}

.logout-modal {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.logout-modal-icon {
  width: 60px;
  height: 60px;
  background: #FFEBEE;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 26px;
  color: var(--danger);
}

.logout-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.logout-modal-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.logout-modal-actions {
  display: flex;
  gap: 12px;
}

.logout-cancel-btn {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--card-border);
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.logout-cancel-btn:hover { background: #F5F0E8; }

.logout-confirm-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: var(--danger);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.logout-confirm-btn:hover { background: #C62828; }

/* ============================================
   ACTION BUTTONS GROUP (tables)
   ============================================ */
.action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.btn-action-view {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #C8E6C9;
  background: #E8F5E9;
  color: #2E7D32;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-action-view:hover { background: #C8E6C9; }

.btn-action-edit {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #FFF9C4;
  background: #FFFDE7;
  color: #F57F17;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-action-edit:hover { background: #FFF9C4; }

.btn-action-delete {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #FFCDD2;
  background: #FFEBEE;
  color: #C62828;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-action-delete:hover { background: #FFCDD2; }
