/* ==================== VARIABLES ==================== */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.1);
  
  --bg-dark: #0f0f14;
  --bg-card: #1a1a24;
  --bg-card-hover: #22222e;
  --bg-input: #14141c;
  
  --text-primary: #ffffff;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-color: #2d2d3a;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  
  --sidebar-width: 260px;
  --header-height: 70px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f0f14 0%, #1a1a2e 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 40px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.logo {
  text-align: center;
  margin-bottom: 30px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.error-message {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 15px;
  padding: 10px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--border-radius-sm);
  display: none;
}

.error-message.show {
  display: block;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

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

/* ==================== APP LAYOUT ==================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-small {
  font-size: 28px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  transition: all 0.2s;
  margin-bottom: 5px;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-icon {
  font-size: 18px;
}

.nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 15px 0;
}

.sidebar-footer {
  padding: 15px;
  border-top: 1px solid var(--border-color);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
}

.content-header {
  height: var(--header-height);
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-header h2 {
  font-size: 22px;
  font-weight: 600;
}

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

.role-badge {
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-badge.admin {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.content-body {
  padding: 30px;
}

/* ==================== SECTIONS ==================== */
.section {
  display: none;
}

.section.active {
  display: block;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 25px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.card-header h3 {
  margin-bottom: 0;
}

.card-description {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
  margin-top: -10px;
}

.welcome-card {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  border-radius: var(--border-radius);
  padding: 30px;
  margin-bottom: 25px;
}

.welcome-card h3 {
  font-size: 24px;
  margin-bottom: 10px;
}

.welcome-card p {
  opacity: 0.9;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 32px;
}

.stat-info h4 {
  font-size: 16px;
  margin-bottom: 4px;
}

.stat-info p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ==================== PLACEHOLDER ==================== */
.placeholder-card {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
}

.placeholder-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.placeholder-card h3 {
  margin-bottom: 10px;
}

.placeholder-card p {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.coming-soon-badge {
  display: inline-block;
  padding: 6px 16px;
  background: var(--warning);
  color: #000;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* ==================== PROFILE ==================== */
.profile-info {
  display: grid;
  gap: 15px;
}

.profile-field {
  display: flex;
  padding: 15px;
  background: var(--bg-input);
  border-radius: var(--border-radius-sm);
}

.profile-field label {
  color: var(--text-muted);
  min-width: 160px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.field-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.field-hint code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary);
}

.save-status {
  margin-left: 15px;
  font-size: 14px;
}

.save-status.success {
  color: var(--success);
}

.save-status.error {
  color: var(--danger);
}

.export-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
}
.export-message.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}
.export-message.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.info-value {
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
}

/* ==================== WARNING PANEL ==================== */
.warning-panel {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 15px 20px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--border-radius-sm);
  margin-bottom: 20px;
}

.warning-icon {
  font-size: 24px;
}

.warning-text strong {
  display: block;
  color: var(--warning);
  margin-bottom: 4px;
}

.warning-text p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

/* ==================== TABLE ==================== */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
}

.data-table tr:hover {
  background: var(--bg-card-hover);
}

.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.status-badge.inactive {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

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

.loading-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 20px;
}

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

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body,
.modal form {
  padding: 25px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 10px;
}

.link-box {
  display: flex;
  gap: 10px;
  margin: 15px 0;
}

.link-box input {
  flex: 1;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.link-note {
  color: var(--warning);
  font-size: 13px;
}

/* ==================== RESET PASSWORD PAGE ==================== */
.form-title {
  text-align: center;
  margin-bottom: 8px;
}

.form-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 25px;
}

.loading-text {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.error-card,
.success-card {
  text-align: center;
  padding: 20px 0;
}

.error-icon,
.success-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.error-card h3,
.success-card h3 {
  margin-bottom: 10px;
}

.error-card p,
.success-card p {
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ==================== LOGIN FOOTER ==================== */
.login-footer {
  text-align: center;
  padding-top: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ==================== BAN CHECK SECTION ==================== */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 25px 0;
}

.check-form h4 {
  margin-bottom: 15px;
}

.check-form textarea {
  width: 100%;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 14px;
  resize: vertical;
}

.check-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.results-panel {
  margin-top: 20px;
}

.results-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.results-header h4 {
  margin: 0;
}

.results-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.results-list {
  max-height: 500px;
  overflow-y: auto;
}

.result-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 15px;
  margin-bottom: 10px;
}

.result-item:hover {
  border-color: var(--primary);
}

.result-admin {
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 5px;
}

.result-time {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.result-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.result-nick {
  display: inline-block;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.loading-panel {
  text-align: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

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

.no-results {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.no-results .icon {
  font-size: 48px;
  margin-bottom: 15px;
}

/* ==================== MENU TOGGLE BUTTON ==================== */
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  margin-right: 12px;
  line-height: 1;
  -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
  z-index: 101;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.menu-toggle:hover {
  opacity: 0.8;
}

.menu-toggle:active {
  opacity: 0.6;
}

/* ==================== SIDEBAR OVERLAY ==================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  :root {
    /* Sidebar with text labels on mobile */
    --sidebar-width: 260px;
    --header-height: 60px;
  }

  html {
    /* Prevent zoom on input focus */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    /* Prevent zoom gestures */
    touch-action: pan-x pan-y;
    overflow-x: hidden;
  }

  body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .menu-toggle {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.active {
    pointer-events: auto;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: var(--sidebar-width);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    padding: 15px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .logo-small {
    font-size: 24px;
    flex-shrink: 0;
  }

  .logo-text {
    font-size: 18px;
    font-weight: 700;
    display: block;
    white-space: nowrap;
  }

  .sidebar-nav {
    padding: 10px 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    padding: 12px 15px;
    gap: 12px;
    font-size: 14px;
    white-space: nowrap;
    display: flex;
    align-items: center;
  }

  .nav-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
  }

  .nav-text {
    display: block;
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border-color);
  }

  .sidebar-footer .btn {
    font-size: 14px;
    padding: 10px 12px;
    width: 100%;
    justify-content: flex-start;
  }

  .sidebar-footer .nav-icon {
    width: auto;
  }

  .sidebar-footer .nav-text {
    display: inline;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }

  .content-header {
    height: auto;
    min-height: var(--header-height);
    padding: 12px 15px;
    flex-wrap: nowrap;
    gap: 12px;
    align-items: center;
    position: relative;
    z-index: 51;
  }

  .content-header h2 {
    font-size: 18px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
  }

  .user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    min-width: 0;
  }

  #user-display-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
    line-height: 1.2;
  }

  .role-badge {
    font-size: 10px;
    padding: 2px 8px;
    flex-shrink: 0;
    line-height: 1.4;
  }

  .content-body {
    padding: 15px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .card {
    padding: 15px;
  }

  .card h3 {
    font-size: 16px;
  }

  .welcome-card {
    padding: 20px;
  }

  .welcome-card h3 {
    font-size: 20px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .stat-card {
    padding: 15px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 14px;
    width: 100%;
  }

  .check-form textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .check-form h4 {
    font-size: 15px;
  }

  .field-hint {
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .field-hint code {
    font-size: 12px;
    white-space: normal;
    word-break: break-word;
  }

  #section-export .form-row {
    gap: 12px;
  }

  #section-export .info-value {
    font-size: 14px;
  }

  .export-message {
    font-size: 14px;
    padding: 12px;
  }

  .loading-panel {
    padding: 24px 16px;
  }

  .btn {
    font-size: 14px;
    padding: 10px 16px;
    white-space: nowrap;
  }

  .btn-full {
    width: 100%;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-content {
    margin: 10px;
    max-width: calc(100% - 20px);
  }

  .modal-header,
  .modal-body,
  .modal form {
    padding: 15px;
  }

  .profile-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .profile-field label {
    min-width: auto;
    font-size: 13px;
  }

  .warning-panel {
    padding: 12px 15px;
    flex-direction: column;
    gap: 10px;
  }

  .warning-icon {
    font-size: 20px;
  }

  .results-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .results-header h4 {
    font-size: 16px;
  }

  .results-badge {
    font-size: 12px;
    padding: 3px 10px;
  }

  .nav-divider {
    margin: 10px 0;
  }

  /* Prevent text selection issues on mobile */
  .nav-item,
  .btn {
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
  }
}
