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

:root {
  /* Courtika Brand Colors */
  --brand-blue: #0071ba;
  --brand-blue-hover: #005287;
  --brand-blue-light: #6db6e6;
  --brand-blue-dark: #00385d;

  /* Theme Surfaces & Glassmorphism */
  --bg-gradient: linear-gradient(135deg, #0a1120 0%, #002847 50%, #0a1120 100%);
  --panel-bg: rgba(15, 29, 50, 0.75);
  --panel-border: rgba(109, 182, 230, 0.18);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Status Accents */
  --accent-blue: #6db6e6;
  --accent-purple: #0071ba;
  --accent-green: #34d399;
  --accent-red: #f87171;

  /* Buttons & Shadows */
  --btn-primary: linear-gradient(135deg, #0071ba 0%, #005287 100%);
  --btn-primary-hover: linear-gradient(135deg, #005287 0%, #00385d 100%);
  --shadow-glow: 0 10px 25px -5px rgba(0, 113, 186, 0.35);

  /* Geometry & Typography */
  --radius-lg: 16px;
  --radius-md: 10px;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Fira Code", monospace;
}

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

/* Custom Sleek Dark Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(10, 17, 32, 0.8);
}

::-webkit-scrollbar-thumb {
  background: rgba(109, 182, 230, 0.25);
  border-radius: 4px;
}

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

/* Accessible Focus States */
*:focus-visible {
  outline: 2px solid var(--brand-blue-light);
  outline-offset: 2px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header Navbar */
.app-header {
  background: rgba(10, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #6db6e6 0%, #0071ba 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(0, 113, 186, 0.4);
}

/* Optional Class if Using Image Asset Logo */
.brand-logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff 0%, #6db6e6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* User Pill & Controls */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 113, 186, 0.1);
  border: 1px solid var(--panel-border);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.user-badge strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Language Toggle Switcher */
.lang-switcher {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 3px;
}

.lang-btn {
  padding: 0.35rem 0.85rem;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 113, 186, 0.4);
}

.lang-btn:hover:not(.active) {
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: var(--btn-primary);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(0, 113, 186, 0.15);
  border-color: rgba(109, 182, 230, 0.4);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--accent-red);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.3);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Main Container Layout */
.main-wrapper {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Glassmorphism Cards */
.card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 1px 1px rgba(0, 113, 186, 0.1);
}

/* Login Page Styling */
.login-container {
  max-width: 420px;
  margin: 4rem auto;
}

.login-card {
  text-align: center;
}

.login-header {
  margin-bottom: 2rem;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(10, 17, 32, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.form-control::placeholder {
  color: #64748b;
  opacity: 1;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 186, 0.25);
}

/* Webkit Autofill Fix for Dark Mode */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover, 
.form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main);
  -webkit-box-shadow: 0 0 0px 1000px #0f1d32 inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* Code & Embed Script Input Styling */
textarea.form-control {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

/* Alert Messages */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.alert-error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--accent-red);
}

.alert-success {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--accent-green);
}

.alert-info {
  background: rgba(0, 113, 186, 0.15);
  border: 1px solid rgba(109, 182, 230, 0.3);
  color: var(--brand-blue-light);
}

/* Bitrix Form Embedded Wrapper */
.bitrix-wrapper {
  background: rgba(0, 113, 186, 0.03);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-height: 400px;
  border: 1px dashed var(--panel-border);
  position: relative;
}

.portal-intro {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.portal-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Admin Dashboard Table */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 1rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.admin-table th,
.admin-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--panel-border);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table th {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-blue-light);
  background: rgba(0, 56, 93, 0.45);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.admin-table tr:hover {
  background: rgba(0, 113, 186, 0.08);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-admin {
  background: rgba(0, 113, 186, 0.25);
  color: var(--brand-blue-light);
  border: 1px solid rgba(109, 182, 230, 0.35);
}

.badge-user {
  background: rgba(0, 82, 135, 0.3);
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.25);
}

.badge-active {
  background: rgba(52, 211, 153, 0.2);
  color: var(--accent-green);
}

.badge-none {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

/* Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #0f1d32;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

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

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--panel-border);
  margin-top: auto;
}

/* QR Code Modal */
.qr-modal {
  max-width: 420px;
}

.qr-preview-img {
  max-width: 280px;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.qr-url-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
  background: rgba(10, 17, 32, 0.5);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}
