@import url('./tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--gw-surface-2);
  color: var(--gw-ink-700);
  line-height: 1.5;
  font-size: 0.9375rem;
  min-height: 100vh;
}

/* --- Layout Architecture (Pattern A: Vertical Navigation Sidebar) --- */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--gw-ink-900);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
  padding: var(--gw-space-5) var(--gw-space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: var(--gw-space-3);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--gw-brand-600);
  color: #ffffff;
  border-radius: var(--gw-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  line-height: 1.2;
}

.sidebar-brand span {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gw-ink-300);
}

.sidebar-logo-spot {
  padding: var(--gw-space-3) var(--gw-space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-logo-spot img {
  max-width: 100%;
  max-height: 60px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: var(--gw-radius-sm);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--gw-space-4) var(--gw-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--gw-space-1);
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gw-ink-500);
  padding: var(--gw-space-3) var(--gw-space-2) var(--gw-space-1);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--gw-space-3);
  padding: var(--gw-space-2) var(--gw-space-3);
  color: var(--gw-ink-300);
  text-decoration: none;
  border-radius: var(--gw-radius-md);
  font-weight: 500;
  transition: all var(--gw-duration-sm) var(--gw-ease-in-out);
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--gw-brand-600);
  color: #ffffff;
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: var(--gw-space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(0, 0, 0, 0.2);
}

.user-profile-summary {
  display: flex;
  align-items: center;
  gap: var(--gw-space-3);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--gw-radius-full);
  background-color: var(--gw-surface-3);
  color: var(--gw-ink-900);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  border: 2px solid var(--gw-brand-600);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-pill {
  display: inline-block;
  font-size: 0.6875rem;
  padding: 1px 6px;
  background-color: rgba(248, 76, 85, 0.2);
  color: var(--gw-brand-600);
  border: 1px solid rgba(248, 76, 85, 0.3);
  border-radius: var(--gw-radius-full);
  font-weight: 600;
  margin-top: 2px;
}

/* --- Main Layout Wrapper --- */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.top-header {
  height: 64px;
  background-color: var(--gw-surface);
  border-bottom: 1px solid var(--gw-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gw-space-6);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gw-ink-900);
  letter-spacing: -0.01em;
}

.top-header-actions {
  display: flex;
  align-items: center;
  gap: var(--gw-space-3);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: var(--gw-space-2);
  padding: var(--gw-space-2) var(--gw-space-3);
  color: var(--gw-ink-500);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-radius-md);
  transition: all var(--gw-duration-sm) var(--gw-ease-in-out);
}

.btn-logout:hover {
  background-color: var(--gw-surface-2);
  color: var(--gw-brand-600);
  border-color: var(--gw-brand-600);
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--gw-space-6);
}

/* --- Component Utilities --- */
.card {
  background: var(--gw-surface);
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-radius-lg);
  padding: var(--gw-space-5);
  box-shadow: var(--gw-shadow-sm);
  transition: box-shadow var(--gw-duration-sm) var(--gw-ease-in-out);
  margin-bottom: var(--gw-space-6);
}

.card:hover {
  box-shadow: var(--gw-shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gw-space-4);
  padding-bottom: var(--gw-space-3);
  border-bottom: 1px solid var(--gw-line);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gw-ink-900);
  display: flex;
  align-items: center;
  gap: var(--gw-space-2);
}

/* Grid System */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gw-space-6);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gw-space-6);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gw-space-6);
}

@media (max-width: 1024px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Stat Widget */
.stat-widget {
  background-color: var(--gw-surface);
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-radius-md);
  padding: var(--gw-space-4);
  display: flex;
  align-items: center;
  gap: var(--gw-space-4);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--gw-radius-md);
  background-color: var(--gw-brand-100);
  color: var(--gw-brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gw-ink-900);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gw-ink-500);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gw-space-2);
  padding: var(--gw-space-2) var(--gw-space-4);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--gw-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--gw-duration-sm) var(--gw-ease-in-out);
}

.btn-primary {
  background-color: var(--gw-brand-600);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--gw-brand-700);
}

.btn-secondary {
  background-color: var(--gw-surface-2);
  color: var(--gw-ink-900);
  border-color: var(--gw-line);
}

.btn-secondary:hover {
  background-color: var(--gw-surface-3);
}

.btn-sm {
  padding: var(--gw-space-1) var(--gw-space-3);
  font-size: 0.8rem;
}

/* Form inputs */
.form-group {
  margin-bottom: var(--gw-space-4);
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gw-ink-900);
  margin-bottom: var(--gw-space-1);
}

.form-control {
  width: 100%;
  padding: var(--gw-space-2) var(--gw-space-3);
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-radius-md);
  background-color: var(--gw-surface);
  color: var(--gw-ink-900);
  transition: border-color var(--gw-duration-sm) var(--gw-ease-in-out);
}

.form-control:focus {
  outline: none;
  border-color: var(--gw-brand-600);
  box-shadow: 0 0 0 3px rgba(248, 76, 85, 0.15);
}

/* Table styling */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background-color: var(--gw-surface-2);
  color: var(--gw-ink-700);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--gw-space-3) var(--gw-space-4);
  border-bottom: 1px solid var(--gw-line);
}

.data-table td {
  padding: var(--gw-space-3) var(--gw-space-4);
  border-bottom: 1px solid var(--gw-line);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: rgba(240, 236, 231, 0.5);
}

/* Tag / Badge Pills */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--gw-radius-full);
  background-color: var(--gw-surface-2);
  color: var(--gw-ink-700);
  border: 1px solid var(--gw-line);
}

.tag-brand {
  background-color: var(--gw-brand-100);
  color: var(--gw-brand-600);
  border-color: rgba(248, 76, 85, 0.3);
}

.tag-info {
  background-color: var(--gw-info-bg);
  color: var(--gw-info);
}

.tag-success {
  background-color: var(--gw-success-bg);
  color: var(--gw-success);
}

/* Pattern C: Custom contenteditable WYSIWYG Editor */
.wysiwyg-container {
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-radius-md);
  background: var(--gw-surface);
  overflow: hidden;
}

.wysiwyg-toolbar {
  background: var(--gw-surface-2);
  border-bottom: 1px solid var(--gw-line);
  padding: var(--gw-space-2);
  display: flex;
  gap: var(--gw-space-1);
  flex-wrap: wrap;
}

.wysiwyg-btn {
  background: var(--gw-surface);
  border: 1px solid var(--gw-line);
  border-radius: var(--gw-radius-sm);
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--gw-ink-900);
  font-weight: 600;
}

.wysiwyg-btn:hover {
  background: var(--gw-brand-100);
  color: var(--gw-brand-600);
  border-color: var(--gw-brand-600);
}

.wysiwyg-area {
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  padding: var(--gw-space-3);
  outline: none;
  font-size: 0.9rem;
}

[contenteditable=true]:empty:before {
  content: attr(placeholder);
  color: var(--gw-ink-300);
  pointer-events: none;
  display: block;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--gw-duration-md) var(--gw-ease-in-out);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--gw-surface);
  width: 100%;
  max-width: 540px;
  border-radius: var(--gw-radius-lg);
  box-shadow: var(--gw-shadow-lg);
  overflow: hidden;
  border: 1px solid var(--gw-line);
}

.modal-header {
  padding: var(--gw-space-4) var(--gw-space-5);
  border-bottom: 1px solid var(--gw-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: var(--gw-space-5);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-footer {
  padding: var(--gw-space-4) var(--gw-space-5);
  border-top: 1px solid var(--gw-line);
  background: var(--gw-surface-2);
  display: flex;
  justify-content: flex-end;
  gap: var(--gw-space-3);
}

/* Discussion message bubbles (MS Teams style alignment) */
.message-thread-list {
  display: flex;
  flex-direction: column;
  gap: var(--gw-space-3);
  width: 100%;
}

.message-bubble {
  max-width: 78%;
  padding: var(--gw-space-3) var(--gw-space-4);
  border-radius: var(--gw-radius-lg);
  box-shadow: var(--gw-shadow-sm);
  transition: all var(--gw-duration-sm) var(--gw-ease-in-out);
}

.message-bubble-other {
  align-self: flex-start;
  background: var(--gw-surface-2);
  border-left: 4px solid var(--gw-ink-500);
  border-top-left-radius: var(--gw-radius-sm);
}

.message-bubble-self {
  align-self: flex-end;
  background: var(--gw-brand-100);
  border: 1px solid rgba(248, 76, 85, 0.3);
  border-right: 4px solid var(--gw-brand-600);
  border-top-right-radius: var(--gw-radius-sm);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gw-space-3);
  font-size: 0.75rem;
  color: var(--gw-ink-500);
  margin-bottom: var(--gw-space-1);
  font-weight: 500;
}

.message-body {
  font-size: 0.9rem;
  color: var(--gw-ink-700);
  line-height: 1.5;
  white-space: pre-wrap;
}
