/* ═══════════════════════════════════════════════════════════════
   CRM Vitiaz — Style principal
   Palette : Marine profond + Rouge élégant + Accent blanc cassé
   ═══════════════════════════════════════════════════════════════ */

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

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --navy:        #0D1F3C;
  --navy-mid:    #172A4F;
  --navy-card:   #1F355E;
  --navy-light:  #2C4673;
  --red:         #C72C41;
  --red-light:   #E55A6C;
  --red-dim:     #8B1C2A;
  --white:       #F8FAFC;
  --white-dim:   #94A3B8;
  --accent:      #4A90D9;
  --success:     #2ECC71;
  --danger:      #E74C3C;
  --border:      rgba(199,44,65,.18);
  --shadow:      0 8px 32px rgba(0,0,0,.45);
  --radius:      12px;
  --radius-sm:   8px;
  --font-main:   'Montserrat', 'Roboto', sans-serif;
  --transition:  .2s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; height: 100%; }

body {
  font-family: var(--font-main);
  background: var(--navy);
  color: var(--white);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Login Screen ───────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(74,144,217,.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(199,44,65,.10) 0%, transparent 60%),
    var(--navy);
  animation: fadeIn .6s ease;
}

.login-card {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow), 0 0 60px rgba(199,44,65,.06);
  animation: slideUp .5s ease;
}

.login-logo { margin-bottom: 36px; }

.logo-emblem {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(199,44,65,.4));
  animation: float 3s ease-in-out infinite;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--red-light);
  margin-bottom: 8px;
  letter-spacing: .03em;
}

.login-subtitle {
  color: var(--white-dim);
  font-size: .95rem;
  font-weight: 400;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: #fff;
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  margin-bottom: 16px;
}
.btn-google:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.btn-google:active { transform: translateY(0); }

.login-note {
  color: var(--white-dim);
  font-size: .8rem;
  margin-bottom: 24px;
}

.lang-toggle-login {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ── Lang Toggle ────────────────────────────────────────────── */
.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--white-dim);
  padding: 4px 10px;
  font-size: .8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-main);
}
.lang-btn:hover,
.lang-btn.active {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red-light);
}

/* ── App Layout ─────────────────────────────────────────────── */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ── Header ─────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-left { display: flex; align-items: center; gap: 14px; }

.header-emblem {
  font-size: 28px;
  filter: drop-shadow(0 0 12px rgba(199,44,65,.5));
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--red-light);
  letter-spacing: .04em;
}

.header-count {
  font-size: .75rem;
  color: var(--white-dim);
  background: var(--navy-light);
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 8px;
}

.header-right { display: flex; align-items: center; gap: 16px; }

.lang-toggle { display: flex; gap: 4px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-light);
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--red-dim);
}

#user-email {
  font-size: .78rem;
  color: var(--white-dim);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white-dim);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}
.btn-icon:hover { border-color: var(--danger); color: var(--danger); }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: var(--transition);
}
.search-bar:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(199,44,65,.12);
}

.search-icon { font-size: 1rem; color: var(--white-dim); flex-shrink: 0; }

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--font-main);
  font-size: .95rem;
  padding: 11px 0;
}
#search-input::placeholder { color: var(--white-dim); }

.search-shortcut {
  font-size: .7rem;
  color: var(--white-dim);
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  flex-shrink: 0;
}

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filter-select {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: var(--font-main);
  font-size: .85rem;
  padding: 8px 12px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23A8A09A' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.filter-select:focus { border-color: var(--red); }

.filter-input {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: var(--font-main);
  font-size: .85rem;
  padding: 8px 12px;
  outline: none;
  transition: var(--transition);
  width: 90px;
}
.filter-input:focus { border-color: var(--red); }

.btn-secondary {
  position: relative;
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: var(--font-main);
  font-size: .85rem;
  padding: 8px 16px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--red); color: var(--red-light); }

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 140px;
  z-index: 50;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fadeIn .15s ease;
}
.export-option {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--white);
  font-family: var(--font-main);
  font-size: .85rem;
  padding: 10px 16px;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.export-option:hover { background: var(--navy-light); color: var(--red-light); }

/* ── Main ────────────────────────────────────────────────────── */
.main { flex: 1; padding: 0; overflow-y: auto; }

.stats-bar {
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  color: var(--white-dim);
}

/* ── Loading & Empty ─────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px;
  color: var(--white-dim);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px;
  color: var(--white-dim);
}
.empty-icon { font-size: 48px; opacity: .4; }

/* ── Table ───────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  width: 100%;
}

.members-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.members-table thead tr {
  background: var(--navy-mid);
  position: sticky;
  top: 0;
  z-index: 10;
}

.members-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--red-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.members-table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.members-table tbody tr {
  transition: var(--transition);
  cursor: pointer;
}
.members-table tbody tr:hover {
  background: var(--navy-card);
}
.members-table tbody tr:last-child td { border-bottom: none; }

/* Colonnes nom/prénom FR+RU */
.name-cell { max-width: 180px; }
.name-primary { font-weight: 600; color: var(--white); }
.name-secondary { font-size: .78rem; color: var(--white-dim); }

/* Grade badge */
.grade-badge {
  display: inline-block;
  background: rgba(199,44,65,.12);
  border: 1px solid var(--red-dim);
  color: var(--red-light);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: .75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* Tag section */
.section-tag {
  display: inline-block;
  background: rgba(74,144,217,.12);
  border: 1px solid rgba(74,144,217,.3);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: .75rem;
  text-transform: capitalize;
}

/* Status */
.status-badge {
  display: inline-block;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: .72rem;
  font-weight: 600;
}
.status-actif { background: rgba(46,204,113,.15); color: var(--success); border: 1px solid rgba(46,204,113,.3); }
.status-archive { background: rgba(231,76,60,.10); color: var(--danger); border: 1px solid rgba(231,76,60,.25); }

/* Action button */
.btn-detail {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white-dim);
  padding: 5px 10px;
  font-size: .78rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-detail:hover { border-color: var(--red); color: var(--red-light); }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
}

.page-btn {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white-dim);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .85rem;
  transition: var(--transition);
  font-family: var(--font-main);
}
.page-btn:hover { border-color: var(--red); color: var(--red-light); }
.page-btn.active {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red-light);
  font-weight: 700;
}
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,10,20,.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}

.modal {
  background: var(--navy-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow), 0 0 80px rgba(199,44,65,.08);
  animation: slideUp .25s ease;
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  background: transparent;
  border: none;
  color: var(--white-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 16px 20px;
  z-index: 10;
  transition: var(--transition);
}
.modal-close:hover { color: var(--white); }

/* ── Member Detail Card (inside modal) ──────────────────────── */
.member-detail { padding: 24px 28px 32px; }

.member-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.member-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--navy-light);
  border: 2px solid var(--red-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.member-detail-name h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}
.member-detail-name .name-ru {
  font-size: 1rem;
  color: var(--white-dim);
  margin-bottom: 8px;
}

.member-detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.detail-section {
  margin-bottom: 24px;
}

.detail-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--red-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.detail-field { }

.detail-label {
  font-size: .72rem;
  color: var(--white-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}

.detail-value {
  font-size: .9rem;
  color: var(--white);
  font-weight: 500;
  word-break: break-word;
}
.detail-value.empty { color: var(--white-dim); font-style: italic; font-weight: 400; }

.detail-list { list-style: none; }
.detail-list li {
  font-size: .88rem;
  color: var(--white);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.detail-list li:last-child { border-bottom: none; }

.tags-list { display: flex; flex-wrap: wrap; gap: 6px; }

.comments-box {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: .85rem;
  color: var(--white-dim);
  line-height: 1.6;
  white-space: pre-wrap;
}
/* ── Modal Error State ────────────────────────────────────────── */
.modal-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 40px;
  text-align: center;
}
.modal-error-icon {
  font-size: 48px;
  color: var(--danger);
  line-height: 1;
}
.modal-error-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--white);
}
.modal-error-message {
  font-size: 0.85rem;
  color: var(--white-dim);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes float {
  0%, 100% { transform: translateY(0) }
  50% { transform: translateY(-8px) }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters { justify-content: flex-start; }
  .search-bar { min-width: 0; }
  .header { padding: 0 12px; }
  #user-email { display: none; }
  .search-shortcut { display: none; }
  .members-table th:nth-child(4),
  .members-table td:nth-child(4),
  .members-table th:nth-child(5),
  .members-table td:nth-child(5) { display: none; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--navy); }
::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--red-dim); }
