/* --- Dashboard Sidebar Layout --- */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}
aside.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
}
aside.sidebar nav#main-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}
aside.sidebar nav#main-nav a,
aside.sidebar nav#main-nav button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0;
  text-align: left;
  padding-left: 24px;
  padding-right: 24px;
  margin: 0;
}
main.main-content {
  flex: 1;
  padding: 0 0 32px 0;
  min-width: 0;
  margin-left: 230px;
}
header.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 32px 32px 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

main.main-content {
  position: relative;
  background: var(--bg);
}
@media (max-width: 900px) {
  .dashboard-layout { flex-direction: column; }
  aside.sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border);
    min-height: auto;
    height: auto;
    max-height: none;
    position: relative;
    top: auto;
    left: auto;
    overflow: visible;
  }
  main.main-content { padding: 0; margin: 16px 0 0; }
  header.page-header { padding: 24px 12px 0 12px; }
  aside.sidebar nav#main-nav a,
  aside.sidebar nav#main-nav button {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f6f8fa;
  --surface: #fff;
  --muted-surface: #f1f3f7;
  --border: #d1d5db;
  --text: #222b45;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --accent: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
}

body[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #12172a;
  --muted-surface: #161c33;
  --border: #2a3252;
  --text: #e7eaf6;
  --muted: #a9b0c6;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --accent: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
}

/* Base */
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prevent layout overflow */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }

header {
  background: linear-gradient(180deg, var(--surface), var(--muted-surface));
  color: var(--text);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  margin-bottom: 20px;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

nav#main-nav {
  background: var(--surface);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
nav#main-nav a, nav#main-nav button {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
  font: inherit;
}
nav#main-nav a:hover, nav#main-nav button:hover {
  background: var(--muted-surface);
  border-color: var(--border);
  color: var(--primary);
}
/* Hide burger menu button on desktop */
#mobile-menu-toggle {
  display: none;
}
@media (max-width: 900px) {
  #mobile-menu-toggle {
    display: block;
    width: 94%;
  }
  nav#main-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    position: relative;
    top: auto;
    left: 0;
    right: 0;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 1000;
    padding: 12px 0 16px 0;
    border-bottom: 1px solid var(--border);
  }
  nav#main-nav a, nav#main-nav button {
    width: 100%;
    text-align: left;
    margin: 0;
    border-radius: 0;
    font-size: 1rem;
    padding: 14px 24px;
    box-shadow: none;
  }
}

.container { padding: 24px; }
.container { margin-left: auto; margin-right: auto; }

.card {
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card h2 { margin: 0 0 12px 0; font-size: 1.1rem; }

/* Buttons */
button, .button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, background .2s ease, box-shadow .2s ease;
  box-shadow: 0 8px 16px rgba(79,70,229,0.25);
  display: inline-block;
  text-decoration: none;
  line-height: 1.2;
  vertical-align: middle;
}
button:hover, .button:hover { background: var(--primary-600); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .65; cursor: not-allowed; }

/* Button variants */
.button-secondary {
  background: #6c757d;
  box-shadow: 0 8px 16px rgba(108,117,125,0.25);
}
.button-secondary:hover { background: #5a6268; }

.button-danger {
  background: #dc3545;
  box-shadow: 0 8px 16px rgba(220,53,69,0.25);
}
.button-danger:hover { background: #c82333; }

.button-small {
  padding: 6px 10px;
  font-size: 0.875rem;
}

/* Action links */
.action-links {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.action-links a, .action-links button {
  text-decoration: none;
}

/* Inputs */
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="datetime-local"], input[type="url"], select, textarea {
  width: 100%;
  max-width: 100%;
  background: var(--muted-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0 12px 0;
  transition: border-color .2s ease, box-shadow .2s ease;
}
/* Avoid intrinsic min-content overflow in grid/flex children */
.grid > * { min-width: 0; }
.card { min-width: 0; }
img, video, iframe { max-width: 100%; height: auto; }
input:not([type]):focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.25);
}
label { color: var(--muted); font-size: .9rem; }

/* Tables */
table { border-collapse: collapse; width:100%; margin-top:15px; }
th, td { border:1px solid var(--border); padding:10px; }
th { background: var(--muted-surface); color: var(--muted); text-align:left; font-weight:600; }
tr:nth-child(even) td { background: rgba(0,0,0,0.03); }
.card { overflow-x: auto; }

/* Badges / status */
.badge { display:inline-block; padding:2px 8px; border-radius:999px; font-size:.8rem; font-weight:600; }
.badge-green { background: rgba(16,185,129,.15); color:#10b981; }
.badge-blue { background: rgba(59,130,246,.15); color:#3b82f6; }
.badge-amber { background: rgba(245,158,11,.15); color:#f59e0b; }
.badge-red { background: rgba(239,68,68,.15); color:#ef4444; }

/* Progress */
.progress-bar { background: var(--muted-surface); border-radius: 8px; overflow: hidden; width:100%; height:10px; }
.progress-bar .fill { height:100%; border-radius: 8px; }
.progress-green { background:#10b981; }
.progress-blue { background:#3b82f6; }

/* Calendar Legend list tweak */
.card ul { margin:0; padding:0; list-style:none; }
.card li { list-style:none; }

/* Links */
a { color: #8ab4ff; }
a:hover { color: #a3c4ff; }

/* Utilities */
.muted { color: var(--muted); }
.grid { display:grid; gap:16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

/* Mobile Responsive Improvements */
@media (max-width: 768px) {
  .container { 
    padding: 12px; 
    max-width: 100% !important;
  }
  
  .card {
    padding: 16px;
    margin-top: 12px !important;
  }
  
  /* Grid layouts to single column */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  
  /* Navigation improvements */
  nav {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9rem;
  }
  
  nav a, nav button {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  
  /* Form inputs full width */
  input:not([type]),
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="url"],
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  
  /* Buttons stack on mobile */
  .button + .button {
    margin-top: 8px;
  }
  
  /* Tables scroll horizontally */
  table {
    font-size: 0.85rem;
  }
  
  th, td {
    padding: 8px 6px;
    white-space: nowrap;
  }
  
  /* Comment sections */
  .comment-item {
    font-size: 0.9rem;
  }
  
  .comment-content {
    word-break: break-word;
  }
  
  /* Task/Project cards */
  .card h2 {
    font-size: 1.3rem;
  }
  
  .card h3 {
    font-size: 1.1rem;
  }
  
  /* Flex containers adjust */
  div[style*="display:flex"] {
    flex-wrap: wrap;
  }
  
  /* Inline forms stack */
  form[style*="display:inline"] {
    display: block !important;
    margin-top: 8px;
  }
  
  /* Badge positioning */
  .badge {
    font-size: 0.7rem;
    padding: 2px 6px;
  }
  
  /* Message/comment edit buttons */
  .edit-comment-btn,
  .save-comment-btn,
  .cancel-edit-btn {
    font-size: 0.75rem !important;
    padding: 4px 8px !important;
  }
  
  /* Portal header adjustments */
  .card[style*="display:flex"] h2 {
    font-size: 1.2rem;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .container {
    padding: 8px;
  }
  
  .card {
    padding: 12px;
  }
  
  nav {
    flex-direction: column;
    align-items: stretch;
  }
  
  nav a, nav button {
    text-align: center;
    width: 100%;
  }
  
  .button {
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
  }
  
  /* Stack floated elements */
  .button[style*="float:right"],
  a[style*="float:right"] {
    float: none !important;
    margin-bottom: 12px;
    display: block;
  }
  
  /* Ensure readable text */
  .muted-small,
  .muted {
    font-size: 0.8rem;
  }
}

/* Product-workspace refinements */
body, input, select, textarea, button, table { font-style: normal; }
.page-header h1, .card h2, .card h3 { font-style: normal; }
.muted { color: var(--muted); }

.record-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  position: sticky;
  top: 118px;
  z-index: 15;
  padding: 10px;
  margin-bottom: 20px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.record-tab {
  appearance: none;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  padding: 9px 13px;
}
.record-tab:hover { background: var(--muted-surface); color: var(--text); }
.record-tab.is-active { background: var(--primary); color: #fff; }
.record-panel[hidden] { display: none !important; }

.record-summary-grid > div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--muted-surface);
}
.record-summary-grid strong { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

.communications-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
.communications-table { width: 100%; table-layout: fixed; }
.communications-table th:nth-child(1), .communications-table td:nth-child(1) { width: 112px; }
.communications-table th:nth-child(2), .communications-table td:nth-child(2) { width: 82px; }
.communications-table th:nth-child(3), .communications-table td:nth-child(3) { width: 72px; }
.communications-table th:nth-child(6), .communications-table td:nth-child(6) { width: 72px; }
.communications-table th:nth-child(7), .communications-table td:nth-child(7) { width: 72px; }
.communications-table th:nth-child(8), .communications-table td:nth-child(8) { width: 150px; }
.communications-table td { overflow-wrap: anywhere; word-break: break-word; vertical-align: top; }
.communications-table td:last-child .button { white-space: normal; margin: 0 0 5px; }

@media (max-width: 900px) {
  .communications-table { min-width: 820px; }
}
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
.danger-zone summary { color: var(--danger); font-weight: 700; cursor: pointer; }

.row-actions { position: relative; display: inline-block; }
.row-actions summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
}
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 190px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.row-actions-menu a, .row-actions-menu button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 10px;
  text-align: left;
  color: var(--text);
  background: transparent;
  box-shadow: none;
  border-radius: 7px;
  font-size: .875rem;
}
.row-actions-menu a:hover, .row-actions-menu button:hover { background: var(--muted-surface); }
.row-actions-menu form { margin: 0; }
.human-date { white-space: nowrap; }

@media (max-width: 900px) {
  .record-tabs { top: 0; border-radius: 0; margin-left: -12px; margin-right: -12px; }
}
