/* ===============================
   SyndicBot — PWA Copropriétaire
   ================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  overscroll-behavior: none;
}

/* ---- Login Screen ---- */
#loginScreen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #1e2d4a 0%, #2563eb 100%);
  color: white;
}

.login-logo {
  font-size: 64px;
  margin-bottom: 16px;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  text-align: center;
}

.login-subtitle {
  font-size: 14px;
  opacity: 0.75;
  margin-bottom: 40px;
  text-align: center;
}

.login-card {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  border: 1px solid rgba(255,255,255,0.2);
}

.login-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  outline: none;
  margin-bottom: 16px;
}

.login-input::placeholder {
  opacity: 0.5;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.login-input:focus {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: white;
  color: #1e40af;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-btn:active {
  opacity: 0.85;
}

.login-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.25);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  display: none;
}

/* ---- App Shell ---- */
#appShell {
  display: none;
}

/* ---- Header ---- */
.owner-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #1e2d4a;
  color: white;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.header-title {
  font-size: 16px;
  font-weight: 600;
}

.header-lot {
  font-size: 12px;
  opacity: 0.65;
  margin-top: 1px;
}

.header-logout {
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

/* ---- Install Banner ---- */
#installBanner {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  background: #3b82f6;
  color: white;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 99;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.install-btn {
  background: white;
  color: #1e40af;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.install-dismiss {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

/* ---- Views ---- */
.owner-view {
  display: none;
  padding: 16px;
  margin-top: 56px;
  padding-bottom: 80px;
  min-height: calc(100vh - 56px - 64px);
}

.owner-view.active {
  display: block;
}

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e2d4a;
  display: flex;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #2a3f5f;
  z-index: 100;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 11px;
  border: none;
  background: none;
  cursor: pointer;
  gap: 3px;
  transition: color 0.15s;
  padding: 0;
}

.bottom-nav-item.active {
  color: #3b82f6;
}

.bn-icon {
  font-size: 22px;
  line-height: 1;
}

/* ---- Cards ---- */
.o-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.o-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ---- KPI Solde ---- */
.solde-card {
  border-radius: 12px;
  padding: 20px 16px;
  margin-bottom: 12px;
  color: white;
}

.solde-card.credit {
  background: linear-gradient(135deg, #10b981, #059669);
}

.solde-card.debit {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.solde-label {
  font-size: 12px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.solde-amount {
  font-size: 28px;
  font-weight: 700;
}

.solde-sub {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 4px;
}

/* ---- ADF Item ---- */
.adf-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.adf-item:last-child {
  border-bottom: none;
}

.adf-label {
  color: #475569;
}

.adf-amount {
  font-weight: 600;
  color: #1e293b;
}

.adf-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-orange { background: #ffedd5; color: #ea580c; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ---- Ticket list ---- */
.ticket-item {
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.ticket-item:last-child {
  border-bottom: none;
}

.ticket-titre {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.ticket-meta {
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Urgence dots ---- */
.urgence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.u1 { background: #94a3b8; }
.u2 { background: #3b82f6; }
.u3 { background: #f59e0b; }
.u4 { background: #f97316; }
.u5 { background: #ef4444; }

/* ---- Bouton action ---- */
.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}

.btn-action:active {
  opacity: 0.85;
}

.btn-action.secondary {
  background: #f1f5f9;
  color: #475569;
}

/* ---- Formulaire ticket ---- */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 15px;
  color: #1e293b;
  background: white;
  outline: none;
  font-family: inherit;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-input:focus,
.form-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* Photo preview */
#photoPreview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 8px;
  display: none;
}

.photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: #f8fafc;
}

/* ---- Messages Chat ---- */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 16px;
}

.msg-row {
  display: flex;
  margin-bottom: 4px;
}

.msg-row.mine {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble-owner {
  background: #3b82f6;
  color: white;
  border-radius: 16px 16px 4px 16px;
}

.msg-bubble-syndic {
  background: #f3f4f6;
  color: #111827;
  border-radius: 16px 16px 16px 4px;
}

.msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 3px;
  text-align: right;
}

.msg-time-syndic {
  text-align: left;
  color: #64748b;
}

.msg-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 0 0;
  border-top: 1px solid #e2e8f0;
  margin-top: 12px;
}

.msg-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 14px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  font-family: inherit;
  outline: none;
}

.msg-textarea:focus {
  border-color: #3b82f6;
}

.msg-send-btn {
  width: 42px;
  height: 42px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- AG ---- */
.ag-item {
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.ag-item:last-child {
  border-bottom: none;
}

.ag-date {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.ag-lieu {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.resolution-item {
  font-size: 13px;
  padding: 6px 10px;
  background: #f8fafc;
  border-radius: 6px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vote-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.vote-pour { background: #dcfce7; color: #16a34a; }
.vote-contre { background: #fee2e2; color: #dc2626; }
.vote-abstention { background: #fef3c7; color: #d97706; }
.vote-absent { background: #f1f5f9; color: #94a3b8; }

/* ---- Compte ---- */
.compte-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.compte-info-row:last-child {
  border-bottom: none;
}

.compte-info-label {
  color: #64748b;
}

.compte-info-value {
  font-weight: 600;
}

/* ---- Loading / Error ---- */
.loading-text {
  text-align: center;
  color: #94a3b8;
  padding: 32px 16px;
  font-size: 14px;
}

.error-text {
  text-align: center;
  color: #ef4444;
  padding: 20px 16px;
  font-size: 14px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  margin: 16px 0 8px;
}

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e2d4a;
  color: white;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
