/* ===================================
   CLUB DE JUDO KOTOKAN - ADMIN PANEL
   =================================== */

:root {
  --sidebar-bg: #1a1f36;
  --sidebar-hover: #252b48;
  --sidebar-active: #2d3561;
  --sidebar-text: #a0aec0;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 260px;
  --header-bg: #ffffff;
  --header-border: #e2e8f0;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #06b6d4;
  --info-light: #cffafe;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --pink: #ec4899;
  --pink-light: #fce7f3;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

body { padding: 0; min-height: 100vh; width: 100% !important; max-width: 100% !important; }

.container, #appView {
  width: 100vw !important;
  max-width: 100vw !important;
  margin: 0 !important;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

/* Typography */
h1 { color: var(--text-primary); font-weight: 700; font-size: 24px; }
h2 { color: var(--text-primary); margin: 0 0 20px; font-weight: 700; font-size: 20px; }
h3 { color: var(--text-primary); margin: 16px 0 10px; font-weight: 600; font-size: 16px; }
h4 { color: var(--text-secondary); margin: 14px 0 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* Section */
.section {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: var(--bg-main); border: 1px solid var(--border); color: var(--text-primary); box-shadow: none; }
.btn-secondary:hover { background: var(--border-light); }

/* Forms */
input, select, textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 4px;
  width: 200px;
  font-size: 14px;
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
textarea { width: 300px; height: 80px; resize: vertical; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }

/* Tables */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg-main); color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
tr:hover { background: var(--border-light); }

/* Status Badges */
.status-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status-active, .status-completed { background: var(--success-light); color: #065f46; }
.status-active::before, .status-completed::before { background: var(--success); }
.status-inactive, .status-cancelled { background: var(--danger-light); color: #991b1b; }
.status-inactive::before, .status-cancelled::before { background: var(--danger); }
.status-pending { background: var(--warning-light); color: #92400e; }
.status-pending::before { background: var(--warning); }

/* Results */
.result { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 16px; max-height: 320px; overflow: auto; }
.result pre { white-space: pre-wrap; word-wrap: break-word; color: var(--text-primary); }

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.15s ease;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-card .stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-card .stat-icon.pink { background: var(--pink-light); color: var(--pink); }
.stat-card .stat-info { flex: 1; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.stat-card .stat-change { font-size: 12px; font-weight: 500; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

.hidden { display: none !important; }

/* Login */
.login-container {
  max-width: 440px;
  margin: 90px auto;
  padding: 40px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 28px; }
.brand-mark { width: 56px; height: 56px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-size: 28px; font-weight: 700; }
.brand-kicker { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.login-container h1 { font-size: 24px; text-align: left; margin: 0; }
.login-label { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.login-container input { width: 100%; margin: 0 0 12px; min-height: 44px; }
.login-container .btn { width: 100%; margin: 12px 0 0; min-height: 44px; }
.login-alt { margin-top: 20px; text-align: center; }
.login-alt p { color: var(--text-secondary); font-size: 14px; margin-bottom: 10px; }
.login-alt .btn { width: auto; min-height: 40px; font-size: 13px; padding: 9px 18px; }
.login-error { background: var(--danger-light); color: var(--danger); padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 15px; font-size: 13px; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header h1 { margin: 0; font-size: 20px; color: var(--text-primary); white-space: nowrap; }
.header-search { flex: 1; max-width: 400px; position: relative; }
.header-search input { width: 100%; padding: 10px 14px 10px 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-main); font-size: 14px; margin: 0; }
.header-search input:focus { background: #fff; }
.header-search::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; pointer-events: none; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--bg-main); color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; position: relative; transition: background 0.15s;
}
.header-icon-btn:hover { background: var(--border); }
.header-icon-btn .badge {
  position: absolute; top: -2px; right: -2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center;
}
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-info span { color: var(--text-primary); font-size: 14px; font-weight: 500; }
#sessionUserEmail { padding: 0; border: none; background: transparent; font-weight: 500; }
.role-badge { padding: 4px 10px; border-radius: 999px; background: var(--purple-light); color: #6d28d9; font-size: 11px; font-weight: 600; }

/* Member Portal */
.member-portal { background: var(--bg-main); color: var(--text-primary); }
.member-portal h2 { border-bottom-color: var(--border); }

/* News Cards */
.news-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 15px; }
.news-card h3 { color: var(--text-primary); margin-bottom: 10px; }
.news-card .meta { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.news-card .content { line-height: 1.6; color: var(--text-secondary); }
.news-card .attachment { margin-top: 12px; padding: 10px; background: var(--bg-main); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.news-card .attachment a { color: var(--accent); text-decoration: none; }
.news-card .attachment img { max-width: 100%; max-height: 300px; border-radius: var(--radius-sm); margin-top: 10px; }

/* Sidebar - Dark Navy */
.sidebar {
  background: var(--sidebar-bg);
  padding: 20px 12px;
  color: var(--sidebar-text);
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  min-height: calc(100vh - 73px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar h3 { margin: 0 0 20px; font-size: 11px; padding-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar .btn {
  background: transparent; color: var(--sidebar-text); text-align: left; padding: 10px 14px; border-radius: var(--radius-sm);
  transition: all 0.15s ease; margin: 0; font-size: 14px; font-weight: 500; min-height: 40px; display: flex; align-items: center; gap: 10px;
  box-shadow: none; border: none; justify-content: flex-start;
}
.sidebar .btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); }
.sidebar .btn.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.sidebar .btn:active { transform: scale(0.99); }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
.sidebar-close { display: none; }

/* Content Area */
.content-area { display: flex; flex-direction: column; min-height: 0; flex: 1; width: 100% !important; min-width: 0; background: var(--bg-main); }
.content-section { overflow-y: auto; height: auto; min-height: 100%; width: 100% !important; display: flex; flex-direction: column; padding: 24px; }

/* Members List */
.members-list-container { border-right: 1px solid var(--border); padding: 20px; background: var(--bg-card); overflow-y: auto; height: 100%; display: flex; flex-direction: column; }
.member-item { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: #fff; cursor: pointer; transition: all 0.15s ease; color: var(--text-primary); }
.member-item:hover { background: var(--border-light); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.member-detail { padding: 20px; overflow-y: auto; height: 100%; flex: 1; background: var(--bg-card); }

/* Collapsible Details */
details { margin-bottom: 12px; padding: 14px; border-radius: var(--radius); border-left: 3px solid var(--border); background: var(--bg-main); }
details[open] { background: var(--bg-card); }
details summary { cursor: pointer; font-weight: 600; outline: none; color: var(--text-primary); list-style: none; }
details summary::-webkit-details-marker { display: none; }
details.summary-cinturon { border-color: var(--warning); background: var(--warning-light); }
details.summary-cinturon summary { color: #b45309; }
details.summary-pagos { border-color: var(--success); background: var(--success-light); }
details.summary-pagos summary { color: #047857; }
details.summary-apoderado { border-color: var(--text-muted); background: var(--border-light); }
details.summary-apoderado summary { color: var(--text-secondary); }

/* Modal */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg-card); padding: 28px; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 1000; min-width: 400px; max-width: 90%;
  max-height: 85vh; overflow-y: auto; border: 1px solid var(--border);
}
.modal h3 { color: var(--text-primary); margin-bottom: 18px; font-size: 18px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }

/* Main Layout */
.main-layout { display: flex; flex: 1; min-height: 0; height: auto; min-height: calc(100vh - 73px); width: 100% !important; max-width: 100% !important; }
.members-layout { display: grid; grid-template-columns: 350px 1fr; gap: 0; flex: 1; min-height: 0; height: 100%; }
.search-input { width: 100%; margin-bottom: 10px; background: #fff; color: var(--text-primary); border: 1px solid var(--border); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* App Brand */
.app-brand { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-size: 18px; font-weight: 700; }

/* Responsive */
@media (max-width: 1024px) { .main-layout { gap: 15px; } }

@media (max-width: 768px) {
  body { padding: 0; }
  .container { height: 100vh; }
  .main-layout { flex-direction: column; gap: 0; }
  .members-layout { grid-template-columns: 1fr; }
  .header { padding: 12px 16px; }
  .header h1 { font-size: 16px; }
  .header-search { display: none; }
  .header #headerLogo { height: 40px !important; }
  .user-info span { font-size: 12px; }
  .user-info .btn { padding: 6px 10px; font-size: 11px; }
  .role-badge { font-size: 10px; padding: 2px 8px; }
  .header-right .btn { padding: 4px 8px !important; font-size: 10px !important; min-width: auto; }
  .header-right { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .content-section { padding: 16px; }
  .section { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: -100%; width: 85%; max-width: 300px; height: 100vh; z-index: 1000;
    transition: left 0.3s ease; box-shadow: 4px 0 20px rgba(0,0,0,0.3); overflow-y: auto; padding: 16px 12px;
  }
  .sidebar.active { left: 0; }
  .sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; display: none; }
  .sidebar-overlay.active { display: block; opacity: 1; }
  .sidebar-close { display: block; background: var(--danger); color: white; border: none; padding: 12px; border-radius: var(--radius-sm); margin-bottom: 16px; cursor: pointer; font-size: 14px; font-weight: 600; min-height: 44px; }
  .mobile-menu-toggle { display: block !important; background: var(--bg-main); color: var(--text-primary); border: 1px solid var(--border); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 18px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
}

@media (min-width: 769px) { .mobile-menu-toggle { display: none !important; } .sidebar-close { display: none !important; } }

/* Mobile content */
@media (max-width: 768px) {
  .content-area { padding: 0; }
  h1 { font-size: 20px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
  .btn { padding: 8px 12px; font-size: 13px; margin: 3px; }
  .form-row { flex-direction: column; }
  .form-row input, .form-row select, .form-row textarea { width: 100%; margin: 5px 0; }
  input, select, textarea { width: 100%; margin: 5px 0; }
  table { font-size: 12px; }
  th, td { padding: 8px 4px; }
  .modal { min-width: 90%; max-width: 95%; padding: 20px; }
  .modal h3 { font-size: 18px; margin-bottom: 15px; }
  .modal-overlay { background: rgba(0,0,0,0.3); }
}

/* Utilities */
.mobile-only { display: none; }
@media (max-width: 768px) { .mobile-only { display: block !important; } .desktop-only { display: none !important; } }
@media (max-width: 768px) { .btn { min-height: 44px; } input, select, textarea { min-height: 44px; } }
