/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(20, 40, 60, 0.85);
  --bg-glass: rgba(0, 174, 239, 0.05);
  --border-glass: rgba(0, 174, 239, 0.12);
  --border-hover: rgba(0, 174, 239, 0.35);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #00aeef;
  --accent-dark: #005f8a;
  --accent-mid: #0082b3;
  --accent-green: #00aeef;
  --accent-amber: #fbbf24;
  --accent-red: #f87171;
  --gradient-primary: linear-gradient(135deg, #00aeef, #005f8a);
  --gradient-card: linear-gradient(135deg, rgba(0,174,239,0.08), rgba(0,95,138,0.08));
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===== LANDING PAGE ===== */
.landing-container {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.landing-bg-glow,
.app-bg-glow {
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0,174,239,0.15) 0%, rgba(0,95,138,0.06) 40%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.landing-header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
  z-index: 1;
}

.logo-mark {
  margin-bottom: 1.2rem;
  animation: pulse-subtle 3s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.landing-title {
  font-size: 2.2rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.landing-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.4rem;
  font-weight: 400;
}

.user-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  transition: all var(--transition);
  cursor: pointer;
}

.user-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: white;
  flex-shrink: 0;
}

.user-info h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.user-info p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.card-arrow {
  margin-left: auto;
  color: var(--text-muted);
  transition: all var(--transition);
}

.user-card:hover .card-arrow {
  color: var(--accent-blue);
  transform: translateX(3px);
}

.landing-footer {
  position: fixed;
  bottom: 1.5rem;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  z-index: 1;
}

/* ===== MANAGEMENT SECTION (Landing) ===== */
.mgmt-section {
  width: 100%;
  max-width: 400px;
  margin-top: 1.2rem;
  position: relative;
  z-index: 1;
}

.mgmt-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.6rem;
  text-align: center;
}

.mgmt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.mgmt-user-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mgmt-user-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 0.2rem;
}

.mgmt-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mgmt-actions .btn {
  justify-content: center;
  font-size: 0.78rem;
  padding: 0.45rem 0.7rem;
}

/* ===== APP PAGE ===== */
.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.2rem 3rem;
  position: relative;
  min-height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.back-link {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  border: 1px solid var(--border-glass);
}

.back-link:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
  border-color: var(--border-hover);
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-title {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.user-badge {
  padding: 0.2rem 0.7rem;
  background: var(--gradient-primary);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-family: inherit;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-import {
  border-color: rgba(0,174,239,0.3);
}

.btn-import:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(0,174,239,0.15);
}

.btn-export {
  border-color: rgba(0,130,179,0.3);
}

.btn-export:hover {
  border-color: var(--accent-mid);
  box-shadow: 0 0 20px rgba(0,130,179,0.2);
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

/* ===== SEARCH ===== */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
  z-index: 1;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0,174,239,0.1);
}

/* ===== FILTERS ===== */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none; /* Hide scrollbar Firefox */
}

.filter-bar::-webkit-scrollbar {
  display: none; /* Hide scrollbar Chrome/Safari */
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.filter-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--gradient-primary);
  border-color: var(--accent-blue);
  color: white;
  box-shadow: 0 2px 10px rgba(0, 174, 239, 0.2);
}

/* ===== CONTACT LIST ===== */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.contact-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  transition: all var(--transition);
  animation: fadeInUp 0.3s ease forwards;
}

.contact-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-phone {
  display: none;
}

.call-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  background: linear-gradient(135deg, rgba(0,174,239,0.15), rgba(0,95,138,0.1));
  border: 1px solid rgba(0,174,239,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-blue);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.call-btn:hover {
  background: linear-gradient(135deg, rgba(0,174,239,0.25), rgba(0,95,138,0.15));
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(0,174,239,0.2);
  transform: translateY(-1px);
}

.call-btn svg {
  flex-shrink: 0;
}

.result-dropdowns {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.result-select {
  flex: 1;
  width: 100%;
  min-width: 140px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 2rem 0.5rem 0.7rem;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238892b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1em;
}

.result-select:focus {
  border-color: var(--accent-blue);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 0 2px rgba(0, 174, 239, 0.15);
}

.result-select option {
  background: var(--bg-body);
  color: var(--text-primary);
}

.result-select.note-saved {
  animation: pulse-border 1.5s ease-out;
}

.note-wrapper {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.note-input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  min-height: 36px;
  max-height: 120px;
  outline: none;
  transition: all var(--transition);
}

.note-input::placeholder {
  color: var(--text-muted);
}

.note-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0,174,239,0.1);
  background: rgba(0,174,239,0.03);
}

.note-saved {
  border-color: rgba(0,174,239,0.5) !important;
}

.note-caller {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-top: 0.55rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.note-caller strong {
  color: var(--accent-blue);
  font-weight: 600;
}

/* Contact card responsive grid for mobile */
@media (max-width: 600px) {
  .contact-card {
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
  }

  .note-wrapper {
    grid-column: 1 / -1;
    flex-direction: column;
    gap: 0.3rem;
  }

  .header-actions {
    width: 100%;
  }

  .btn {
    flex: 1;
    justify-content: center;
  }

  .header-title-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }

  .stats-bar {
    gap: 0.4rem;
  }

  .stat-item {
    padding: 0.5rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }
}

/* ===== PAGINATION ===== */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 1.5rem 0 2rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.page-btn:hover:not(.disabled):not(.active) {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.page-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 10px rgba(0, 174, 239, 0.3);
}

.page-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-dots {
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 0.2rem;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.6rem;
  padding-left: 0.8rem;
  border-left: 1px solid var(--border-glass);
}

.page-jump span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.page-input {
  width: 48px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-align: center;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
  /* Hide number arrows */
  -moz-appearance: textfield;
}

.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-input:focus {
  border-color: var(--accent-blue);
  background: var(--bg-card-hover);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
  position: relative;
  z-index: 1;
}

.empty-state svg {
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.95rem;
  font-weight: 500;
}

.empty-hint {
  font-size: 0.82rem !important;
  margin-top: 0.3rem;
  font-weight: 400 !important;
  color: var(--text-muted);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.7rem 1.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  z-index: 1000;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  white-space: nowrap;
}

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

.toast.toast-success {
  border-color: rgba(0,174,239,0.4);
}

.toast.toast-error {
  border-color: rgba(248,113,113,0.4);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,14,26,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}
