/* MESWAP - Minimalist Brutalist Monochrome Styling (Sans couleurs, sans shadow, no-style un peu) */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --border: #000000;
  --border-light: #cccccc;
  --bg-muted: #f2f2f2;
  --fg-muted: #666666;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* iPhone Safe Area Insets (Notch, Dynamic Island, Home Indicator) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
}

html, body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  height: 100%;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 540px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.main-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* AUTHENTICATION VIEW */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  overflow-y: auto;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  border: 2px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
}

.auth-brand {
  text-align: center;
  margin-bottom: 8px;
}

.auth-brand h1 {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  letter-spacing: 3px;
  font-weight: 900;
  margin-bottom: 4px;
}

.auth-tagline {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
}

.auth-tab-btn {
  background: var(--bg);
  color: var(--fg);
  border: none;
  padding: 9px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  text-align: center;
}

.auth-tab-btn:first-child {
  border-right: 1px solid var(--border);
}

.auth-tab-btn.active {
  background: var(--fg);
  color: var(--bg);
}

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

.auth-info-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
  line-height: 1.3;
}

.auth-submit-btn {
  padding: 12px;
  font-size: 0.95rem;
  margin-top: 4px;
}

/* TOP HEADER */
header.app-header {
  border-bottom: 2px solid var(--border);
  padding-top: calc(10px + var(--safe-top));
  padding-bottom: 10px;
  padding-left: 14px;
  padding-right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  z-index: 20;
}

.brand {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.user-badge button {
  padding: 3px 8px;
  font-size: 0.8rem;
}

/* NAVIGATION TABS */
nav.app-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  z-index: 20;
}

.nav-btn {
  flex: 1;
  background: var(--bg);
  color: var(--fg);
  border: none;
  border-right: 1px solid var(--border);
  padding: 10px 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:last-child {
  border-right: none;
}

.nav-btn.active {
  background: var(--fg);
  color: var(--bg);
}

/* MAIN VIEW CONTAINER */
main#view-container {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* VIEWS */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100%;
}

.view.active {
  display: flex;
}

/* GENERAL BUTTONS & INPUTS */
button, .btn {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  cursor: pointer;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 0;
  transition: background 0.1s, color 0.1s;
}

button:hover, .btn:hover {
  background: var(--fg);
  color: var(--bg);
}

button:active, .btn:active {
  background: var(--fg);
  color: var(--bg);
}

button.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--border);
}

button.btn-primary:hover {
  background: var(--bg);
  color: var(--fg);
}

button.btn-mini {
  padding: 3px 6px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

button.btn-danger {
  border-color: var(--border);
  color: var(--fg);
}

button:disabled, .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-muted);
  color: var(--fg-muted);
  border-color: var(--border-light);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

input, textarea, select {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 0;
  outline: none;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  border: 2px solid var(--border);
  padding: 7px 9px;
}

/* FEED VIEW */
.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.feed-instructions {
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--bg-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border-light);
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px calc(14px + var(--safe-bottom)) 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-card-wrapper {
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: pan-y;
}

.feed-swipe-background {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.85rem;
  background: var(--bg-muted);
  border: 1px dashed var(--border);
  z-index: 1;
}

.feed-card {
  position: relative;
  background: var(--bg);
  border: 2px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2;
  cursor: grab;
  transition: transform 0.15s ease-out;
}

.feed-card.swiping {
  transition: none;
  cursor: grabbing;
}

.feed-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
}

.sender-tag {
  font-weight: 900;
}

.status-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border: 1px solid var(--border);
  text-transform: uppercase;
}

.status-pill.unread {
  background: var(--fg);
  color: var(--bg);
}

.status-pill.read {
  background: var(--bg);
  color: var(--fg);
}

.feed-card-content {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.feed-card-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.feed-card-text {
  font-size: 0.95rem;
  word-break: break-word;
  white-space: pre-wrap;
  flex: 1;
}

.feed-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.action-buttons-row {
  display: flex;
  gap: 6px;
}

/* CONVERSATION VIEW */
.conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  font-family: var(--font-mono);
}

.conv-title {
  font-weight: 900;
  font-size: 1rem;
}

.conv-counter {
  font-size: 0.85rem;
}

.conv-swipe-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 14px calc(14px + var(--safe-bottom)) 14px;
  gap: 12px;
  overflow-y: auto;
}

.conv-swipe-hints {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.conv-card-frame {
  flex: 1;
  min-height: 240px;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}

.conv-card-meta {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg-muted);
}

.conv-card-body {
  flex: 1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.conv-photo-container {
  display: flex;
  justify-content: center;
  max-height: 240px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.conv-photo {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.conv-text {
  font-size: 1.05rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.conv-card-tap-bar {
  padding: 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
}

.conv-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.answer-drawer {
  border-top: 2px solid var(--border);
  padding-top: 10px;
  padding-left: 14px;
  padding-right: 14px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--bg);
}

.answer-drawer-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.answer-drawer-inputs {
  display: flex;
  gap: 8px;
}

/* FRIENDS & COMPOSE VIEWS */
.friends-container {
  padding: 14px 14px calc(16px + var(--safe-bottom)) 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.box-section {
  border: 2px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.box-title {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.friend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
}

.friend-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.friend-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
}

.friend-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.friend-item-actions {
  display: flex;
  gap: 6px;
}

.photo-preview-wrap {
  position: relative;
  border: 1px solid var(--border);
  padding: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-muted);
}

.photo-preview-wrap img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
}

.btn-remove-photo {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  font-size: 0.7rem;
  background: var(--fg);
  color: var(--bg);
}

/* ADMIN PANEL STYLING */
.admin-container {
  padding: 14px 14px calc(16px + var(--safe-bottom)) 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
}

.admin-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}

.admin-title {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 1px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 1px solid var(--border);
}

.admin-subtab-btn {
  background: var(--bg);
  color: var(--fg);
  border: none;
  border-right: 1px solid var(--border);
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  text-align: center;
}

.admin-subtab-btn:last-child {
  border-right: none;
}

.admin-subtab-btn.active {
  background: var(--fg);
  color: var(--bg);
}

.admin-subtab-content {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.admin-subtab-content.active {
  display: flex;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.admin-stat-card {
  border: 2px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 900;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.admin-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
}

.admin-user-card {
  border: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.admin-user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.admin-user-stats {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-light);
}

.admin-message-card {
  border: 1px solid var(--border);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}

.admin-msg-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 4px;
}

.admin-msg-body {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.9rem;
}

.admin-msg-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.admin-msg-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  z-index: 100;
}

.modal-dialog {
  background: var(--bg);
  border: 2px solid var(--border);
  width: 100%;
  max-width: 420px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.modal-title {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1rem;
  text-transform: uppercase;
}

/* EMPTY STATES */
.empty-box {
  padding: 30px 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-muted);
  border: 1px dashed var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

/* TOAST NOTIFICATION */
#toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 1000;
  border: 2px solid var(--bg);
  display: none;
  pointer-events: none;
}

#toast.show {
  display: block;
}
