/* Light theme similar to LawSurface style */
:root {
  --bg: #f3f4f6;
  --bg-elevated: #ffffff;
  --accent: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --text-main: #0f172a;
  --text-muted: #6b7280;
  --border-subtle: #e5e7eb;
  --danger: #ef4444;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-soft: 0 12px 40px rgba(15, 23, 42, 0.08);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

/* Sidebar */

.sidebar {
  background: #ffffff;
  border-inline-end: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 18px 16px;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-lg);
  background: #f9fafb;
  box-shadow: 0 6px 18px rgba(15,23,42,0.06);
}

.logo-circle {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #fbbf24, #f59e0b);
  color: #111827;
  font-size: 20px;
}

.brand-text { display: flex; flex-direction: column; }

.brand-ar { font-weight: 700; font-size: 14px; }

.brand-en { font-size: 11px; color: var(--text-muted); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.nav-item {
  all: unset;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: 0.16s ease;
}

.nav-item:hover {
  background: #f3f4ff;
  color: #1f2937;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(37,99,235,0.35);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Switch */

.switch { position: relative; display: inline-block; width: 34px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #e5e7eb;
  transition: .2s;
  border-radius: 999px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--accent);
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider { background-color: #bfdbfe; }
input:checked + .slider:before { transform: translateX(16px); }

/* Main */

.main { padding: 22px 22px 28px; }

.section { display: none; }
.section.visible { display: block; }

.section-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
}
.section-header p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.card-header h2 { margin: 0; font-size: 15px; }

/* Stats */

.stat-card { position: relative; overflow: hidden; }

.stat-label { font-size: 12px; color: var(--text-muted); }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

/* Table */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th,
.data-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #e5e7eb;
}
.data-table th {
  text-align: right;
  color: var(--text-muted);
  font-weight: 500;
}
.data-table tr:last-child td { border-bottom: none; }

/* Docs */

.doc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-title { font-size: 13px; }
.doc-meta { font-size: 11px; color: var(--text-muted); }

/* Tasks */

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-title { font-size: 13px; }
.task-meta { font-size: 11px; color: var(--text-muted); }

/* Buttons */

.btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: 0.16s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #ffffff;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); }

.icon-btn {
  all: unset;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: 0.16s ease;
}
.icon-btn:hover { background: #e5e7eb; }

/* AI Layout */

.ai-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  gap: 14px;
}

.ai-chat {
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.chat-window {
  flex: 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 10px;
  margin-bottom: 10px;
  background: #f9fafb;
  overflow-y: auto;
  max-height: 380px;
}

.msg { display: flex; margin-bottom: 8px; }

.msg-bubble {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  max-width: 95%;
  line-height: 1.5;
}

.msg.bot .msg-bubble {
  background: #e5e7eb;
  color: #111827;
}

.msg.user { justify-content: flex-end; }

.msg.user .msg-bubble {
  background: var(--accent);
  color: #ffffff;
}

.chat-input-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
}
.chat-input-row input {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: var(--text-main);
  font-size: 13px;
}
.chat-input-row input:focus { outline: 1px solid var(--accent); }

.ai-status { font-size: 11px; color: var(--text-muted); }

.hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Notes */

.ai-notes textarea {
  width: 100%;
  min-height: 240px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--text-main);
  padding: 8px 10px;
  font-size: 12px;
  resize: vertical;
}
.ai-notes textarea:focus { outline: 1px solid var(--accent); }

/* Responsive */

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .sidebar-footer { display: none; }
}

@media (max-width: 720px) {
  .ai-layout { grid-template-columns: 1fr; }
}
