* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --surface: #f4f4f5;
  --card: #ffffff;
  --text: #0a0a0a;
  --muted: #71717a;
  --border: #e5e7eb;
  --primary: #0a0a0a;
  --primary-foreground: #ffffff;
  --danger: #111111;
  --hover: #f4f4f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --call-header-height: 64px;
  --call-controls-height: 88px;
}

body {
  font-family: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

body .is-hidden {
  display: none !important;
}

button,
input {
  font-family: inherit;
}

.screen {
  display: none;
  min-height: 100dvh;
}

.screen.active {
  display: block;
}

#loginScreen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#callScreen.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.login-container {
  width: min(420px, 100%);
  padding: 32px 28px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
  border: 1px solid var(--border);
}

.login-container h1 {
  font-size: 24px;
  margin-bottom: 6px;
  font-weight: 600;
}

.login-container p {
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 14px;
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-radius: 50%;
  transition: all 0.2s ease;
  background: var(--bg);
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.1);
}

.error-message {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 16px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 300px;
  margin: 0 auto;
}

.key {
  padding: 16px;
  font-size: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  color: var(--text);
}

.key:hover {
  background: var(--hover);
  box-shadow: var(--shadow-sm);
}

.key:active {
  transform: scale(0.97);
}

.header {
  background: var(--card);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--text);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.home-container {
  max-width: 960px;
  margin: 24px auto 48px;
  padding: 0 20px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card h2 {
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 600;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 12px;
  font-weight: 600;
}

.call-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-selector label {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  background: var(--card);
  font-weight: 600;
  font-size: 14px;
}

.mode-selector input[type="radio"] {
  display: none;
}

.mode-selector label:has(input:checked) {
  border-color: var(--text);
  background: var(--text);
  color: var(--primary-foreground);
}

.mode-selector label:hover {
  background: var(--hover);
}

.call-code-display {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
}

.call-code-display.hidden {
  display: none;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.code-box span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text);
}

.join-call input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
  background: var(--card);
  color: var(--text);
}

.join-call input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.file-upload {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-progress.hidden {
  display: none;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--text);
  transition: width 0.3s;
}

.file-list {
  display: grid;
  gap: 12px;
}

.file-item {
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  border: 1px solid transparent;
}

.file-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.file-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.file-icon {
  width: 36px;
  height: 36px;
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 1px solid var(--border);
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 14px;
}

.file-meta {
  font-size: 12px;
  color: var(--muted);
}

.btn-primary,
.btn-secondary,
.btn-icon {
  padding: 10px 20px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--text);
  color: var(--primary-foreground);
  width: 100%;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--hover);
}

.btn-icon {
  padding: 8px;
  background: transparent;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.btn-icon:hover {
  background: var(--hover);
  border-color: var(--border);
}

.call-header {
  background: var(--card);
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.call-status {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    margin-top: 55px;
    position: absolute;
}

.call-container {
  position: relative;
  flex: 1;
  min-height: 0;
  padding-bottom: var(--call-controls-height);
  background: var(--bg);
  overflow: hidden;
}

.voice-call-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 5;
  padding: 24px 20px;
  text-align: center;
}

.voice-call-view.hidden {
  display: none;
}

.voice-call-avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--text);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.voice-call-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.voice-call-status {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 24px;
}

.voice-call-timer {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.participants {
  position: relative;
  z-index: 2;
  padding: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.participant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.participant-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--text);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
}

.participant-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.vdo-container {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 1;
}

.vdo-container.hidden {
  display: none;
}

.vdo-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.shared-file {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 60;
}

.shared-file.modal-view {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shared-file.hidden {
  display: none;
}

.file-viewer {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.shared-file.modal-view .file-viewer {
  width: min(1200px, 96vw);
  height: min(90vh, 960px);
  background: var(--bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.file-header {
  padding: 16px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shared-file-alert {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ffeb3b;
  color: #111;
  border-bottom: 2px solid #d4b900;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 2000;
}

.shared-file-alert.hidden {
  display: none;
}

.shared-file-alert button {
  background: #111;
  color: #ffeb3b;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.shared-file-alert button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

#fileViewerContent {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fileViewerContent.excel-viewer {
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
}

.excel-table-wrapper {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 16px;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  background: var(--card);
}

.excel-table td,
.excel-table th {
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 14px;
  vertical-align: top;
  min-width: 120px;
}

.excel-table td {
  background: #fff;
}

.excel-table td[contenteditable="true"] {
  outline: 2px solid transparent;
  cursor: text;
}

.excel-table td[contenteditable="true"]:focus {
  outline-color: var(--text);
  background: #f9fafb;
}

@media (max-width: 640px) {
  .excel-table {
    min-width: 360px;
  }

  .excel-table td,
  .excel-table th {
    font-size: 12px;
    padding: 6px 8px;
    min-width: 100px;
  }
}

#fileViewerContent img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

#fileViewerContent iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.call-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--call-controls-height);
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  gap: 12px;
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 70px;
}

.control-btn:hover {
  background: var(--hover);
}

.control-btn.danger {
  background: var(--text);
  color: var(--primary-foreground);
  border-color: var(--text);
}

.control-btn.active {
  background: var(--text);
  color: var(--primary-foreground);
  border-color: var(--text);
}

.control-btn .icon {
  font-size: 20px;
}

.control-btn .label {
  font-size: 11px;
  font-weight: 600;
}

.chat-drawer {
  position: absolute;
  top: var(--call-header-height);
  bottom: var(--call-controls-height);
  right: -100%;
  width: 100%;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 50;
  border-left: 1px solid var(--border);
}

.chat-drawer.open {
  right: 0;
}

#callScreen.chat-open .call-container {
  padding-bottom: 0;
}

#callScreen.chat-open .call-controls {
  display: none;
}

#callScreen.chat-open .chat-drawer {
  right: 0;
  bottom: 0;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header h3 {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
}

.chat-message {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-message.own {
  align-self: flex-end;
}

.chat-message.other {
  align-self: flex-start;
}

.message-sender {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 0 8px;
}

.message-text {
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  border: 1px solid var(--border);
}

.chat-message.own .message-text {
  background: var(--text);
  color: var(--primary-foreground);
  border-color: var(--text);
  border-radius: 16px 16px 4px 16px;
}

.chat-message.other .message-text {
  background: var(--card);
  color: var(--text);
  border-radius: 16px 16px 16px 4px;
}

.chat-input {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  background: var(--card);
  align-items: center;
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 16px;
  background: var(--card);
  transition: all 0.2s;
}

.chat-input input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card);
  padding: 28px;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  text-align: left;
}

.modal-header h3 {
  font-weight: 600;
  font-size: 18px;
  color: var(--text);
}

.new-pin-display {
  font-size: 40px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 6px;
  margin: 20px 0;
}

.warning {
  color: var(--text);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 16px 0;
  text-align: left;
  border: 1px solid var(--border);
}

.file-selector-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.file-selector-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.file-selector-item:hover {
  background: var(--hover);
  border-color: var(--border);
}

#callScreen[data-mode="chat"] .participants,
#callScreen[data-mode="chat"] .vdo-container {
  display: none;
}

#callScreen[data-mode="chat"] .chat-drawer {
  right: 0;
}

/* Enhanced auth modal styles */
.auth-modal-content {
  max-width: 640px;
  padding: 32px;
}

.auth-instructions {
  margin-bottom: 24px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--hover) 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.auth-instructions p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  transition: all 0.2s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.auth-actions .btn-primary,
.auth-actions .btn-secondary {
  flex: 1;
  padding: 12px 20px;
  font-size: 15px;
}

/* Auth setup section styles */
.auth-setup-section {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 2px solid var(--border);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}



.setup-instructions {
  margin-bottom: 28px;
  padding: 20px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: var(--radius-md);
  border: 2px solid #bae6fd;
}

.setup-instructions h4 {
  font-size: 17px;
  font-weight: 700;
  color: #0c4a6e;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-steps {
  margin: 0;
  padding-left: 24px;
}

.setup-steps li {
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: #0c4a6e;
}

.setup-steps li:last-child {
  margin-bottom: 0;
  font-weight: 600;
}

/* Enhanced QR wrapper styles */
.qr-wrapper {
  margin: 28px 0;
  padding: 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.qr-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.qr-image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px auto;
  padding: 20px;
  background: white;
  border-radius: var(--radius-sm);
}
