/* =============================================
   KIRALCORE × BEAUTY - Main Stylesheet
   ============================================= */

:root {
  /* Premium Dark Theme */
  --bg-primary: #030712;
  --bg-secondary: #0f172a;
  --bg-gradient: radial-gradient(circle at top right, #1e1b4b, #030712);

  /* Brand: Neon Cyan × Deep Indigo */
  --brand-primary: #00f5ff;
  --brand-secondary: #6366f1;
  --brand-glow: rgba(0, 245, 255, 0.4);

  /* Glassmorphism Refined */
  --glass-bg: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(12px);

  /* Neutrals */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-dim: rgba(255, 255, 255, 0.05);

  /* Status Levels */
  --status-pending: #fbbf24;
  --status-success: #10b981;
  --status-danger: #ef4444;
  --status-info: #3b82f6;

  /* Typography */
  --font-main: 'Inter', -apple-system, sans-serif;
  --font-display: 'Inter', sans-serif;

  /* --- LEGACY COMPATIBILITY MAPPINGS --- */
  --cyan-neon: var(--brand-primary);
  --electric-blue: var(--brand-secondary);
  --bright-cyan: #22d3ee;
  --gray-cool: var(--text-muted);
  --border-glow: var(--brand-glow);
  --font-family: var(--font-main);
  --red-soft: var(--status-danger);
  --emerald: var(--status-success);
  --sky-blue: var(--status-info);
  --amber: var(--status-pending);
  --card-bg: var(--bg-secondary);
}

/* Base Aesthetics */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Custom Scrollbar Premium */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand-primary);
  box-shadow: 0 0 10px var(--brand-glow);
}

/* Typography */
h1 {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Links */
a {
  color: var(--cyan-neon);
  text-decoration: none;
  transition: all 0.3s ease;
}

a:hover {
  color: var(--bright-cyan);
}

/* Form Elements */
input,
select,
textarea {
  font-family: var(--font-family);
  font-size: 1rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-glow);
  border-radius: 0.75rem;
  background: rgba(5, 10, 30, 0.8);
  color: white;
  width: 100%;
  transition: all 0.3s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-cool);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--cyan-neon);
  box-shadow: 0 0 20px rgba(0, 245, 255, 0.2);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2300F5FF' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

select option {
  background: var(--bg-primary);
  color: white;
}

/* Table Styles Premium */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: var(--bg-secondary);
  padding: 1.25rem 1rem;
  font-weight: 600;
  color: var(--brand-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--glass-border);
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

tr:hover td {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

/* Layout Containers */
.app-container {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-primary);
}

.main-content {
  flex: 1;
  margin-left: 280px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  padding: 2.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.ai-insight-card {
  order: 10;
}

/* Sidebar Refined */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: 1.5rem 0;
}

.logo-section {
  padding: 0 2rem 2rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-section img {
  height: 42px;
  filter: drop-shadow(0 0 10px var(--brand-glow));
}

.logo-section span {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, var(--brand-primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar nav {
  flex: 1;
  padding: 0 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
  background: var(--brand-primary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  color: var(--text-muted);
  border-radius: 0.75rem;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 0.25rem;
}

.nav-item i {
  width: 20px;
  height: 20px;
  stroke-width: 2px;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: var(--brand-primary);
  background: rgba(0, 245, 255, 0.1);
}

.nav-divider {
  margin: 1.5rem 1.25rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}

/* Navbar Premium */
.navbar {
  height: 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2.5rem;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--border-dim);
  border-radius: 100px;
  border: 1px solid var(--glass-border);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
  background: rgba(0, 245, 255, 0.05);
}

/* Logout Button */
.btn-logout {
  margin: 1rem;
  padding: 0.75rem 1.5rem;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red-soft);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  text-align: center;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.3);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

/* Login Container */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card .logo {
  height: 80px;
  margin-bottom: 1rem;
}

.login-card h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  background: linear-gradient(to right, var(--cyan-neon), var(--electric-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.25rem;
  border-radius: 0.75rem;
}

.tab {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--gray-cool);
  cursor: pointer;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.tab:hover {
  color: white;
}

.tab.active {
  background: linear-gradient(to right, var(--cyan-neon), var(--electric-blue));
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-content form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Test Link */
.test-link {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--gray-cool);
  font-size: 0.875rem;
}

.test-link:hover {
  color: var(--cyan-neon);
}

/* Form Container (Public) */
.form-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.form-card {
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.form-card img {
  height: 64px;
  margin-bottom: 1rem;
}

.form-card h2 {
  margin-bottom: 2rem;
}

.form-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

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

/* Uzman Container */
.uzman-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.uzman-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  background: rgba(5, 10, 30, 0.95);
  border-bottom: 1px solid var(--border-glow);
}

.uzman-header img {
  height: 48px;
}

.uzman-header h2 {
  flex: 1;
}

.uzman-content {
  flex: 1;
  padding: 2rem;
}

/* Filters */
.filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.filters input,
.filters select {
  max-width: 200px;
}

/* Stats Grid Premium */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.75rem;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 1.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--brand-primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: rgba(0, 245, 255, 0.3);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 1rem;
  background: rgba(0, 245, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
}

.stat-icon i {
  width: 28px;
  height: 28px;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

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

/* Glass Card & Section Titles */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 1.25rem;
  padding: 1.75rem;
}

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

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* List Items (Dashboard Recent) */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-dim);
}

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

.list-item-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-main);
}

.list-item-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Avatars */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--brand-secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--glass-border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--gray-cool);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-glow);
  border-top-color: var(--cyan-neon);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  color: white;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  z-index: 1000;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.toast.show {
  transform: translateX(0);
}

.toast-success {
  background: linear-gradient(to right, var(--emerald), #059669);
}

.toast-error {
  background: linear-gradient(to right, var(--red-soft), #DC2626);
}

.toast-info {
  background: linear-gradient(to right, var(--sky-blue), var(--electric-blue));
}

.toast-warning {
  background: linear-gradient(to right, var(--amber), #D97706);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border-glow);
  border-radius: 1rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--gray-cool);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.modal-close:hover {
  color: white;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-glow);
}

/* Audio Player */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0.5rem;
}

.audio-player audio {
  flex: 1;
  height: 32px;
}

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--cyan-neon), var(--electric-blue));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .section-title {
    font-size: 1.5rem;
    line-height: 1.2;
    word-break: break-word;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    max-width: 100%;
  }

  #page-title {
    display: none;
  }

  .navbar {
    padding: 0 1rem;
  }

  .content {
    padding: 1rem;
    width: 100%;
    overflow-x: hidden;
  }

  /* Responsive Cards for Tables */
  .glass-card table thead {
    display: none;
  }

  .glass-card table,
  .glass-card table tbody,
  .glass-card table tr,
  .glass-card table td {
    display: block;
    width: 100%;
  }

  .glass-card table tr {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-dim);
    padding-bottom: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0.75rem;
    padding: 1rem;
  }

  .glass-card table tr:last-child {
    margin-bottom: 0;
  }

  .glass-card table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    word-break: break-word;
  }

  .glass-card table td:last-child {
    border-bottom: none;
    justify-content: flex-end;
    padding-top: 1rem;
  }

  .glass-card table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--brand-primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 1rem;
    text-align: left;
    min-width: 80px;
    flex-shrink: 0;
  }

  /* Fix content overflow */
  .glass-card table td>*:not(:first-child) {
    flex: 1;
    text-align: right;
  }

  /* Adjust Modal for Mobile */
  .modal-content {
    margin: auto;
    width: calc(100% - 2rem);
    height: auto;
    max-height: 85vh;
    border-radius: 1.5rem !important;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  }

  .modal-header {
    padding: 1.5rem;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-dim);
    flex-shrink: 0;
  }

  .modal-header h3 {
    font-size: 1.1rem;
    padding-right: 1.5rem;
    word-break: break-word;
    line-height: 1.4;
  }

  .modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    padding-bottom: 20px;
    /* Reduced since footer is separate */
  }

  .modal-footer {
    padding: 1.5rem;
    background: var(--bg-secondary);
    position: sticky;
    bottom: 0;
    z-index: 10;
    border-top: 1px solid var(--border-dim);
    flex-shrink: 0;
  }

  /* Improved Touch Targets */
  .btn,
  .nav-item,
  input,
  select {
    min-height: 48px;
  }

  .glass-card {
    padding: 1rem;
    border-radius: 0.75rem;
  }

  /* Global Overflow Fix */
  body,
  html {
    overflow-x: hidden;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .login-card,
  .form-card {
    padding: 1.5rem;
  }

  .modal-content {
    margin: 0;
    width: 100%;
    border-radius: 0;
  }

  /* Ensure no negative margins or wide elements */
  .row,
  .grid,
  .flex {
    max-width: 100vw;
  }
}