/**
 * @file lawyer-common.css
 * Shared sidebar + top-bar styles for the lawyer portal.
 * Used by: page--node--munsif-legal--lawyer, lawyer-judgment-intelligence.
 */

/* ── CSS variables ─────────────────────────────────────────────────────── */
:root {
  --primary:  #1e40af;
  --secondary: #0f766e;
  --accent:   #ea580c;
  --light:    #f8fafc;
  --dark:     #1e293b;
  --success:  #059669;
  --warning:  #d97706;
  --danger:   #dc2626;
  --sidebar:  #0f172a;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 280px;
  background: var(--sidebar);
  color: white;
  padding: 0;
  overflow-y: auto;
  z-index: 1000;
  transition: all 0.3s;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand i {
  color: #60a5fa;
}

.sidebar-menu {
  padding: 1rem 0;
}

.menu-section {
  margin-bottom: 1.5rem;
}

.menu-section-title {
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.5rem;
  color: #cbd5e1;
  text-decoration: none;
  transition: all 0.3s;
  position: relative;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.menu-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, transparent 100%);
  color: white;
  border-left: 3px solid #3b82f6;
}

.menu-item i {
  width: 20px;
  margin-right: 0.75rem;
}

.menu-badge {
  margin-left: auto;
  background: #dc2626;
  color: white;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-weight: 600;
}

/* ── Main content layout ───────────────────────────────────────────────── */
.main-content {
  margin-left: 280px;
  padding: 0;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* ── Top bar ───────────────────────────────────────────────────────────── */
.top-bar {
  background: white;
  padding: 1rem 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 999;
}

.search-bar {
  position: relative;
  flex: 1;
  max-width: 600px;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: all 0.3s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.search-bar .fa-search {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── User profile ──────────────────────────────────────────────────────── */
.user-profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.3s;
}

.user-profile:hover {
  background: var(--light);
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  font-size: 0.75rem;
  color: #64748b;
}

/* ── User dropdown ─────────────────────────────────────────────────────── */
.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin-top: 0.5rem;
  min-width: 200px;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.user-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--dark);
  text-decoration: none;
  transition: all 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
}

.user-dropdown-item:hover {
  background: var(--light);
  color: var(--primary);
}

.user-dropdown-item i {
  margin-right: 0.75rem;
  width: 18px;
}

.user-dropdown-item.logout {
  color: var(--danger);
  border-top: 1px solid #e2e8f0;
}

.user-dropdown-item.logout:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

/* ── Page layout ───────────────────────────────────────────────────────── */
.page-content {
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: #64748b;
  font-size: 0.95rem;
}

.view-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .main-content {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 1rem;
  }

  .top-bar {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .search-bar {
    max-width: 100%;
  }
}

/* ── Top-bar live search ───────────────────────────────────────────────── */
.search-bar {
  position: relative;
}

.lawyer-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 2000;
  overflow: hidden;
  display: none;
}

.lawyer-search-dropdown.open {
  display: block;
}

.lsd-result {
  display: flex;
  flex-direction: column;
  padding: .65rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}

.lsd-result:last-of-type {
  border-bottom: none;
}

.lsd-result:hover,
.lsd-result:focus {
  background: #f0f4ff;
  outline: none;
}

.lsd-result-title {
  font-size: .875rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lsd-result-meta {
  font-size: .75rem;
  color: #64748b;
  margin-top: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lsd-footer {
  display: block;
  padding: .6rem 1rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
  background: #f8fafc;
  text-align: center;
  text-decoration: none;
  border-top: 1px solid #e2e8f0;
}

.lsd-footer:hover {
  background: #eff6ff;
}

.lsd-empty {
  padding: .8rem 1rem;
  font-size: .85rem;
  color: #64748b;
  text-align: center;
}

.lsd-spinner {
  padding: .8rem 1rem;
  font-size: .85rem;
  color: #94a3b8;
  text-align: center;
}

/* ── Similar Cases page ────────────────────────────────────────────────── */
.sc-back-row {
  margin-bottom: 1rem;
}

.sc-back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}

.sc-back-link:hover {
  text-decoration: underline;
}

.sc-source-label {
  color: #475569;
  font-size: .9rem;
}

/* ── Sidebar collapse ──────────────────────────────────────────────────── */
.sidebar-toggle-btn {
  position: fixed;
  left: 267px;       /* 280px - half button width */
  top: 84px;
  width: 26px;
  height: 26px;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1002;
  color: #64748b;
  font-size: .62rem;
  transition: left 0.3s ease, color 0.2s;
  box-shadow: 2px 0 6px rgba(0,0,0,.3);
}
.sidebar-toggle-btn:hover { color: #fff; border-color: #475569; }

.sidebar-toggle-btn .stb-icon {
  display: inline-block;
  transition: transform 0.3s ease;
}

/* Collapsed state — sidebar */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .main-content { margin-left: 64px; }
body.sidebar-collapsed .sidebar-toggle-btn { left: 51px; }
body.sidebar-collapsed .sidebar-toggle-btn .stb-icon { transform: rotate(180deg); }

body.sidebar-collapsed .sidebar-header {
  padding: 1.25rem 0;
  display: flex;
  justify-content: center;
}
body.sidebar-collapsed .sidebar-brand span { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; }

body.sidebar-collapsed .menu-section-title { display: none; }
body.sidebar-collapsed .menu-item span    { display: none; }
body.sidebar-collapsed .menu-badge        { display: none; }
body.sidebar-collapsed .menu-item {
  justify-content: center;
  padding: 0.875rem 0;
}
body.sidebar-collapsed .menu-item i { margin-right: 0; width: auto; }
