/* ============================================================
   PadelMind v2.0 — Premium Dark Theme
   ============================================================ */

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

:root {
  --font-main: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-base: #0a0e17;
  --bg-card: #111827;
  --bg-card2: #1a2236;
  --bg-card3: #0d1320;
  --bg-input: #0f1629;
  --bg-hover: rgba(99, 234, 216, 0.04);

  --border: rgba(99, 234, 216, 0.08);
  --border-focus: rgba(99, 234, 216, 0.3);

  --text-primary: #e8ecf4;
  --text-secondary: #94a3b8;
  --text-muted: #52617a;

  --accent-cyan: #63ead8;
  --accent-orange: #ff8a50;
  --accent-purple: #a78bfa;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-blue: #60a5fa;
  --accent-yellow: #fbbf24;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);

  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ============================================================
   LAYOUT — App Shell
   ============================================================ */
.app-wrapper { display: flex; min-height: 100vh; }

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

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--bg-base);
  margin-bottom: 14px;
}

.sidebar-logo h1 {
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.sidebar-logo .version {
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px; letter-spacing: 0.5px;
}

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 8px 12px 6px;
}

.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  color: var(--text-secondary); font-weight: 500;
  font-size: 13px; transition: var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
}

.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active {
  background: rgba(99, 234, 216, 0.1);
  color: var(--accent-cyan);
  font-weight: 600;
}
.sidebar-nav a.active i { color: var(--accent-cyan); }

.sidebar-nav a .nav-badge {
  margin-left: auto; background: var(--accent-cyan); color: var(--bg-base);
  font-size: 9px; font-weight: 800; padding: 2px 8px; border-radius: 10px;
}

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

.user-badge { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: var(--bg-base);
}
.user-info .name { font-weight: 600; font-size: 13px; }
.user-info .role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
  margin-left: auto; background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 16px;
  padding: 6px; border-radius: 6px; transition: var(--transition);
}
.btn-logout:hover { color: var(--accent-red); background: rgba(248,113,113,0.1); }

/* MAIN CONTENT */
.main-content { flex: 1; margin-left: 260px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}
.topbar-title {
  font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
}
.topbar-actions { display: flex; gap: 10px; }

.page-body { padding: 28px 32px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border: none; border-radius: 8px;
  font-family: var(--font-main); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  text-decoration: none; white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #4fd1c5);
  color: var(--bg-base);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(99,234,216,0.3); transform: translateY(-1px); }

.btn-secondary { background: var(--bg-card2); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-focus); }

.btn-orange { background: linear-gradient(135deg, var(--accent-orange), #f97316); color: var(--bg-base); }
.btn-danger { background: rgba(248,113,113,0.15); color: var(--accent-red); }
.btn-danger:hover { background: rgba(248,113,113,0.25); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-icon { padding: 8px; min-width: 34px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent, var(--accent-cyan)); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 12px 16px; text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card3);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(99,234,216,0.04);
  font-size: 13px;
}
.data-table tr:hover td { background: var(--bg-hover); }
.actions-cell { display: flex; gap: 6px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-draft { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-active { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-done { background: rgba(96,165,250,0.15); color: #60a5fa; }
.badge-pending { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-playing { background: rgba(99,234,216,0.15); color: var(--accent-cyan); }
.badge-warning { background: rgba(255,138,80,0.15); color: var(--accent-orange); }
.badge-bye { background: rgba(148,163,184,0.1); color: #64748b; }
.badge-info { background: rgba(167,139,250,0.15); color: var(--accent-purple); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control, .form-select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary);
  font-family: var(--font-main); font-size: 13px;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(99,234,216,0.1);
}
.form-control::placeholder { color: var(--text-muted); }
.form-select { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; padding: 4px; border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--accent-red); background: rgba(248,113,113,0.1); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ============================================================
   TABS
   ============================================================ */
.tab-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 20px; }
.tab-nav button {
  padding: 12px 18px; background: none; border: none;
  font-family: var(--font-main); font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.tab-nav button:hover { color: var(--text-secondary); }
.tab-nav button.active { color: var(--accent-cyan); border-bottom-color: var(--accent-cyan); }

.tab-pane { display: none; padding: 20px; }
.tab-pane.active { display: block; }

/* ============================================================
   AI CHAT INTERFACE
   ============================================================ */
.ai-panel {
  background: var(--bg-card);
  border: 1px solid rgba(99,234,216,0.15);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ai-panel-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(99,234,216,0.06), rgba(167,139,250,0.06));
  border-bottom: 1px solid rgba(99,234,216,0.1);
  display: flex; align-items: center; gap: 12px;
}
.ai-panel-header .ai-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--bg-base); flex-shrink: 0;
}
.ai-panel-header h3 { font-size: 16px; font-weight: 700; }
.ai-panel-header .ai-provider {
  font-size: 11px; color: var(--accent-cyan); font-weight: 600;
}

.ai-chat-body {
  min-height: 300px; max-height: 500px; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

.ai-message {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 13px; line-height: 1.7;
}
.ai-message.user {
  align-self: flex-end;
  background: rgba(99,234,216,0.1);
  border: 1px solid rgba(99,234,216,0.15);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}
.ai-message.assistant {
  align-self: flex-start;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-input-bar {
  display: flex; gap: 10px; padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card3);
}
.ai-input-bar textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 200px;
  padding: 12px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-primary); font-family: var(--font-main); font-size: 13px;
}
.ai-input-bar textarea:focus { outline: none; border-color: var(--accent-cyan); }
.ai-input-bar button {
  padding: 0 20px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: var(--bg-base); font-weight: 700; cursor: pointer;
  transition: var(--transition);
}
.ai-input-bar button:hover { box-shadow: 0 4px 20px rgba(99,234,216,0.3); }

/* AI Action Buttons */
.ai-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.ai-action-btn {
  padding: 10px 18px; border-radius: 10px;
  border: 1px dashed rgba(99,234,216,0.2);
  background: rgba(99,234,216,0.03);
  color: var(--accent-cyan); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 8px;
}
.ai-action-btn:hover {
  background: rgba(99,234,216,0.08);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

/* ============================================================
   FIXTURE / BRACKET
   ============================================================ */
.fixture-day {
  margin-bottom: 24px;
}
.fixture-day-header {
  font-size: 16px; font-weight: 700;
  padding: 10px 0; margin-bottom: 12px;
  border-bottom: 2px solid var(--accent-cyan);
  display: flex; align-items: center; gap: 10px;
}

.match-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  align-items: center; gap: 16px;
  transition: var(--transition);
}
.match-card:hover { border-color: var(--border-focus); }
.match-card .team { font-weight: 600; font-size: 13px; }
.match-card .team.left { text-align: right; }
.match-card .vs {
  font-size: 11px; font-weight: 800; color: var(--text-muted);
  padding: 4px 10px; background: var(--bg-card3); border-radius: 6px;
}
.match-card .score {
  display: flex; gap: 6px; font-family: var(--font-mono);
  font-weight: 600; font-size: 14px;
}
.match-card .score .set {
  padding: 4px 8px; background: var(--bg-card); border-radius: 4px;
  min-width: 28px; text-align: center;
}
.match-card .meta {
  font-size: 11px; color: var(--text-muted);
  display: flex; gap: 12px; align-items: center;
}

/* Posiciones Table */
.posiciones-table th { font-size: 10px !important; padding: 8px 10px !important; }
.posiciones-table td { padding: 8px 10px !important; font-size: 12px; }
.posiciones-table .pos-badge {
  width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
}
.pos-1 { background: rgba(251,191,36,0.15); color: var(--accent-yellow); }
.pos-2 { background: rgba(148,163,184,0.15); color: #94a3b8; }
.pos-clasifica { background: rgba(52,211,153,0.1); color: var(--accent-green); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh; display: flex;
}
.login-side-art {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card2));
  position: relative; overflow: hidden;
}
.login-side-art::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(99,234,216,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 30%, rgba(167,139,250,0.06) 0%, transparent 50%),
    radial-gradient(circle at 60% 80%, rgba(255,138,80,0.04) 0%, transparent 50%);
}
.login-art-content { position: relative; text-align: center; padding: 40px; }
.login-art-icon { font-size: 64px; display: block; margin-bottom: 24px; }
.login-art-title {
  font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1;
}
.login-art-title .accent {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-art-sub {
  font-size: 14px; color: var(--text-secondary); margin-top: 16px; line-height: 1.8;
}
.login-form-side {
  width: 480px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-base); padding: 40px;
}
.login-form-box { width: 100%; max-width: 360px; }
.form-header h2 { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.form-header p { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.alert {
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-warning { background: rgba(255,138,80,0.1); border: 1px solid rgba(255,138,80,0.2); color: var(--accent-orange); }
.alert-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.2); color: var(--accent-green); }
.alert-info { background: rgba(99,234,216,0.1); border: 1px solid rgba(99,234,216,0.2); color: var(--accent-cyan); }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid transparent; border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Nivel badge */
.nivel-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  font-weight: 800; font-size: 12px;
}

/* ============================================================
   PUBLIC FIXTURE PAGE
   ============================================================ */
.public-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.public-header h1 {
  font-size: 24px; font-weight: 800;
}

.grupo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}
.grupo-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.grupo-card-header .cat-dot {
  width: 12px; height: 12px; border-radius: 50%;
}

.search-bar {
  position: relative;
}
.search-bar i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
}
.search-bar input {
  padding-left: 38px;
}

/* ============================================================
   CONFIG PAGE
   ============================================================ */
.config-provider-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}
.config-provider-card.selected {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(99,234,216,0.1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .topbar { padding: 16px; }
  .page-body { padding: 16px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .login-side-art { display: none; }
  .login-form-side { width: 100%; }
  .match-card { grid-template-columns: 1fr; gap: 8px; }
}
