/* ==========================================================================
   CSS Custom Properties & Theming (Tailwind Aesthetic Migration)
   ========================================================================== */
:root {
  --background: #F8FAFC;
  --foreground: #1b1b1d;
  --card: #FFFFFF;
  --card-foreground: #1b1b1d;
  --popover: #FFFFFF;
  --popover-foreground: #1b1b1d;
  --primary: #0F172A;
  --primary-foreground: #FFFFFF;
  --secondary: #dde2f8;
  --secondary-foreground: #151b2b;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --accent: #2563eb;
  --accent-foreground: #ffffff;
  --destructive: #ba1a1a;
  --destructive-foreground: #ffffff;
  --border: #E2E8F0;
  --input: #E2E8F0;
  --ring: #2563eb;
  --radius: 12px;
  --sidebar-background: #0B1120;
  --sidebar-foreground: #ffffff;
  --sidebar-primary: #ffffff;
  --sidebar-primary-foreground: #0B1120;
  --sidebar-accent: rgba(255, 255, 255, 0.1);
  --sidebar-accent-foreground: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --header-background: #ffffff;
  --header-foreground: #0F172A;
  --header-border: var(--border);
}

.dark-mode {
  --background: #000000;
  --foreground: #ffffff;
  --card: #1c1c1e;
  --card-foreground: #ffffff;
  --popover: #1c1c1e;
  --popover-foreground: #ffffff;
  --primary: #8ab4f8;
  --primary-foreground: #000000;
  --secondary: #2c2c2e;
  --secondary-foreground: #ffffff;
  --muted: #2c2c2e;
  --muted-foreground: #b3b3b8; /* Brightened inactive text */
  --accent: #8ab4f8;
  --accent-foreground: #000000;
  --destructive: #ff453a;
  --destructive-foreground: #ffffff;
  --border: #38383a;
  --input: #1c1c1e;
  --ring: #8ab4f8;
  --sidebar-background: #1c1c1e;
  --sidebar-foreground: #ffffff;
  --sidebar-primary: #ffffff;
  --sidebar-primary-foreground: #000000;
  --sidebar-accent: rgba(255, 255, 255, 0.1);
  --sidebar-accent-foreground: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --header-background: #09090b;
  --header-foreground: #f4f4f5;
  --header-border: #27272a;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
  border-color: var(--border);
  box-sizing: border-box;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  background-color: var(--input) !important;
  color: var(--foreground) !important;
}


/* ==========================================================================
   Custom Elements & Components
   ========================================================================== */

/* Error Tooltips */
error {
  cursor: help;
  position: relative;
  z-index: 10;
}

error[severity="major"] {
  text-decoration: underline;
  text-decoration-color: var(--destructive);
  text-decoration-style: wavy;
}

error[severity="minor"] {
  text-decoration: underline;
  text-decoration-color: #f59e0b; /* Orange/Warning color */
  text-decoration-style: wavy;
}

error[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--card-foreground);
  color: var(--card);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
  z-index: 20;
  margin-top: 8px; /* space between text and tooltip */
}

/* ==========================================================================
   App Layout (Navigation & Views)
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 256px;
  background-color: var(--sidebar-background);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  z-index: 50;
}
.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 1.5rem;
  color: var(--sidebar-primary);
}
.sidebar-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}
.sidebar-footer {
  padding: 1rem 0;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-menu {
  display: flex;
  flex-direction: column;
  padding: 0 1rem;
  gap: 0.25rem;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #9ca3af; /* Gray 400 */
  cursor: pointer;
  text-align: left;
  font-size: 0.875rem;
  transition: all 0.2s;
  border-left: 4px solid transparent;
}
.nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}
.nav-btn.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 700;
  border-left-color: #ffffff;
}
.sidebar-separator {
  height: 1px;
  background-color: var(--sidebar-border);
  margin: 1rem 0;
}
.conference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}
#close-conference-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #9ca3af;
}

/* Main Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#app-container {
  flex: 1;
  overflow-y: auto;
  background-color: var(--background);
}

/* Header */
.app-header {
  height: 64px;
  background-color: var(--header-background);
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 30;
}
.app-header h1 {
  color: var(--header-foreground) !important;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-right {
  display: flex;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  padding: 0.5rem 1rem;
}
.btn:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}
.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
  box-shadow: none;
}
.btn-outline:hover {
  background-color: #f8fafc; /* hover gray */
  color: var(--foreground);
  transform: none;
}
.btn-ghost {
  background: transparent !important;
  color: inherit !important;
  border: none !important;
  box-shadow: none !important;
}
.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05) !important;
}
.dark-mode .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1) !important;
}
.avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  border: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
}
.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dropdown {
  position: relative;
}
.dropdown-content {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  width: 224px;
  background-color: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  z-index: 50;
  padding: 0.25rem;
}
.dropdown-content.hidden {
  display: none;
}
.dropdown-label {
  padding: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.dropdown-separator {
  height: 1px;
  background-color: var(--border);
  margin: 0.25rem -0.25rem;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.dropdown-item:hover {
  background-color: #f1f5f9;
  color: var(--foreground);
}
.text-destructive {
  color: var(--destructive) !important;
}

/* Views & Cards */
.view {
  display: none;
  padding: 2rem;
  max-width: 1440px;
  margin: 0 auto;
}
.view.active {
  display: block;
}
.card {
  background-color: var(--card);
  color: var(--card-foreground);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.card h2, .card h3 {
  margin-top: 0;
  color: var(--primary);
  font-weight: 700;
}

/* ==========================================================================
   Tabs Component
   ========================================================================== */
.tabs-list {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
  width: 100%;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--muted-foreground);
  transition: all 0.2s;
  margin-bottom: -2px;
}
.tab-btn:hover {
  color: var(--foreground);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ==========================================================================
   Utility Classes (Tailwind equivalents)
   ========================================================================== */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.text-sm { font-size: 0.875rem; }
.bg-muted { background-color: var(--muted); }
.p-4 { padding: 1rem; }
.rounded-lg { border-radius: 0.5rem; }
.h-96 { height: 24rem; }
.overflow-y-auto { overflow-y: auto; }
.text-foreground { color: var(--foreground); }
.text-muted-foreground { color: var(--muted-foreground); }
.hidden { display: none !important; }
.text-primary { color: var(--primary); }

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5); /* #0F172A with opacity */
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden {
  display: none;
}
.modal-content {
  background: var(--background);
  color: var(--foreground);
  width: 100%;
  max-width: 28rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  border: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 700;
}
.modal-header p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}
.modal-body {
  padding: 1.5rem 0;
}

/* ==========================================================================
   Toasts Notification System
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}
.toast {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  min-width: 300px;
  max-width: 420px;
  transition: opacity 0.3s ease;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Mirror Mode */
body.mirror-mode aside.sidebar { display: none !important; }
body.mirror-mode header.app-header { display: none !important; }
body.mirror-mode .main-wrapper { margin-left: 0 !important; }
body.mirror-mode .view { padding: 2rem; }
body.mirror-mode .card { border: none; box-shadow: none; }
body.mirror-mode * { font-size: 1.1em; }

/* ==========================================================================
   Role Toggle & Mode Wrappers
   ========================================================================== */
.role-indicator-container {
    display: flex;
    align-items: center;
    margin-right: 1rem;
}

.delegate-badge {
    background: var(--muted);
    color: var(--muted-foreground);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
}

.mode-toggle {
    position: relative;
    display: inline-block;
    width: 140px;
    height: 34px;
    background: var(--muted);
    border-radius: 9999px;
    cursor: pointer;
    overflow: hidden;
}

.mode-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: .4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 26px;
    width: 66px;
    left: 4px;
    bottom: 4px;
    background-color: var(--card);
    transition: .4s;
    border-radius: 9999px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mode-toggle input:checked + .toggle-slider::before {
    transform: translateX(66px);
}

.toggle-label {
    z-index: 1;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    transition: color 0.3s;
    text-align: center;
    width: 50%;
}

.mode-toggle input:not(:checked) + .toggle-slider .toggle-label.chair {
    color: var(--foreground);
}

.mode-toggle input:checked + .toggle-slider .toggle-label.present {
    color: var(--foreground);
}

.mode-bubble {
    position: relative;
    background: transparent;
    padding-top: 1rem;
}

.mode-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 0.5rem;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-badge svg {
    width: 24px;
    height: 24px;
}

/* ==========================================================================
   Segmented Control (Roll Call)
   ========================================================================== */
.status-segmented-control {
    display: inline-flex;
    background-color: var(--muted);
    border-radius: var(--radius);
    padding: 0.25rem;
    gap: 0.25rem;
}

.status-segmented-control label {
    cursor: pointer;
    position: relative;
    margin: 0;
}

.status-segmented-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.status-segmented-control span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: calc(var(--radius) - 0.25rem);
    color: var(--muted-foreground);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.status-segmented-control input[type="radio"]:checked + span {
    background-color: var(--card);
    color: var(--foreground);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 600;
}

.status-segmented-control input[value="Present"]:checked + span {
    color: #0ea5e9;
}
.status-segmented-control input[value="Present and Voting"]:checked + span {
    color: #16a34a;
}
.status-segmented-control input[value="Not Present"]:checked + span {
    color: var(--destructive);
}

/* Override imported Google Docs inline styles to support Dark/Light theme switching */
.res-document-container,
.res-document-container * {
    color: var(--foreground) !important;
}

/* ==========================================================================
   Mobile Warning Overlay
   ========================================================================== */
#mobile-warning-overlay {
    display: none;
}

@media (max-width: 768px) {
    body:not(.force-desktop) #mobile-warning-overlay {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: var(--background);
        z-index: 999999;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        text-align: center;
    }
    body:not(.force-desktop) {
        overflow: hidden;
    }
}
