/* 
 * CVELS Reusable Components & Unified Design System
 * Tight, compact UI with consistent spacing and styling
 */

/* ========== CSS VARIABLES ========== */
:root {
  /* Brand Colors - Richer, more contrast */
  --gold: #c5a059;
  --gold-light: #e9d1a1;
  --gold-dark: #846a3a;
  --gold-rgb: 197, 160, 89;
  --ink: #f2e8d4;
  --ink-dim: #b8a98f;
  --ink-dark: #4a3b2a;
  
  /* Backgrounds - Deeper, more atmospheric */
  --bg-dark: rgba(12, 8, 5, 0.92);
  --bg-darker: rgba(8, 5, 3, 0.96);
  --bg-medium: rgba(24, 18, 12, 0.94);
  --bg-light: rgba(45, 35, 25, 0.6);
  
  /* Borders & Strokes - More metallic */
  --border-color: rgba(100, 80, 60, 0.4);
  --border-gold: rgba(197, 160, 89, 0.25);
  --border-gold-bright: rgba(197, 160, 89, 0.8);
  --border-inner: rgba(255, 255, 255, 0.05);
  
  /* Shadows - More depth */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.8);
  --shadow-inset: inset 0 2px 6px rgba(0, 0, 0, 0.8);
  --shadow-gold: 0 0 15px rgba(197, 160, 89, 0.3);
  
  /* Spacing (compact) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  
  /* Typography */
  --font-family: "Segoe UI", "Roboto", Tahoma, Geneva, Verdana, sans-serif;
  --font-title: "YoungSerif", "Georgia", serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-md: 17px;
  --font-size-lg: 20px;
  --font-size-xl: 28px;
}

/* ========== PANEL COMPONENT ========== */
.panel {
  position: relative;
  background: 
    linear-gradient(180deg, rgba(30, 22, 15, 0.95) 0%, rgba(15, 10, 5, 0.98) 100%),
    url('/images/ui_bg2.jpg') center / 100% 100% no-repeat;
  border: 1px solid #4a3b2a;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xl), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(4px);
  overflow: hidden;
}

/* Ornate corner accents */
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-image: linear-gradient(135deg, var(--gold-dark) 0%, transparent 20%, transparent 80%, var(--gold-dark) 100%) 1;
  pointer-events: none;
  z-index: 2;
  opacity: 0.5;
}

.panel-content {
  position: relative;
  z-index: 1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid rgba(197, 160, 89, 0.2);
  position: relative;
}

.panel-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.panel-sm { padding: var(--space-sm); }
.panel-md { padding: var(--space-md); }
.panel-lg { padding: var(--space-xl); }

/* ========== COMPACT PANEL ========== */
.panel-compact {
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  background: 
    linear-gradient(180deg, rgba(30, 22, 15, 0.9) 0%, rgba(15, 10, 5, 0.95) 100%),
    url('/images/ui_bg2.jpg') center / 100% 100% no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
}

/* ========== HEADER COMPONENT ========== */
.header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.header h1, .panel-header h1 {
  font-family: var(--font-title);
  font-size: var(--font-size-xl);
  font-weight: normal;
  color: var(--gold-light);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 10px rgba(197, 160, 89, 0.3);
  margin: 0;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header h2, .panel-header h2 {
  font-family: var(--font-title);
  font-size: var(--font-size-lg);
  font-weight: normal;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  margin: 0;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header p {
  color: var(--ink-dim);
  font-size: var(--font-size-md);
  margin-top: var(--space-xs);
}

/* ========== BUTTON COMPONENT ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px var(--space-xl);
  min-height: 36px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  border: 1px solid #846a3a;
  background: linear-gradient(180deg, #6d5532 0%, #4a3b2a 100%);
  color: #f2e8d4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:hover {
  background: linear-gradient(180deg, #846a3a 0%, #5a4a3a 100%);
  border-color: var(--gold-light);
  box-shadow: 0 4px 8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

.btn:active {
  background: linear-gradient(180deg, #4a3b2a 0%, #3a2b1a 100%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
  transform: translateY(1px);
}

.btn:disabled {
  filter: grayscale(100%) opacity(0.4);
  cursor: not-allowed;
  transform: none !important;
}

/* Button Sizes */
.btn-sm {
  padding: 4px 12px;
  min-height: 28px;
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: 12px 32px;
  min-height: 48px;
  font-size: var(--font-size-md);
}

/* Button Variants */
.btn-secondary {
  background: linear-gradient(180deg, #4a3b2a 0%, #2a1b0a 100%);
  border-color: #3a2b1a;
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #5a4a3a 0%, #3a2b1a 100%);
  border-color: #4a3b2a;
}

.btn-danger {
  background: linear-gradient(180deg, #8b2a2a 0%, #5a1a1a 100%);
  border-color: #a03a3a;
}

.btn-danger:hover {
  background: linear-gradient(180deg, #a03a3a 0%, #7a2a2a 100%);
  border-color: #c54a4a;
}

.btn-success {
  background: linear-gradient(180deg, #3a5a2a 0%, #2a3b1a 100%);
  border-color: #4a6a3a;
}

.btn-success:hover {
  background: linear-gradient(180deg, #4a6a3a 0%, #3a4b2a 100%);
  border-color: #5a7a4a;
}

/* ========== INPUT COMPONENT ========== */
.input, 
input[type="text"], 
input[type="email"], 
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #4a3b2a;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  min-height: 36px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: border-color 0.2s ease;
}

.input:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(0, 0, 0, 0.5);
}

/* ========== SLOT COMPONENT (RPG Style) ========== */
.slot {
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #4a3b2a;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.slot:hover {
  border-color: var(--gold);
  background: rgba(197, 160, 89, 0.1);
  box-shadow: inset 0 0 15px rgba(197, 160, 89, 0.2);
}

.slot.active {
  border-color: var(--gold-light);
  box-shadow: 0 0 10px rgba(197, 160, 89, 0.4), inset 0 0 10px rgba(197, 160, 89, 0.2);
}

.slot img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.slot .count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px black;
  pointer-events: none;
}

/* ========== DIVIDER ========== */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(197, 160, 89, 0.3) 50%, transparent 100%);
  margin: var(--space-md) 0;
  width: 100%;
}

/* ========== FORM GROUP ========== */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--gold-light);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.form-group-inline {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.form-group-inline label {
  margin-bottom: 0;
  white-space: nowrap;
}

/* ========== GRID LAYOUTS ========== */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.grid-compact { gap: var(--space-sm); }
.grid-loose { gap: var(--space-xl); }

/* ========== CARD COMPONENT ========== */
.card {
  background: 
    linear-gradient(180deg, rgba(30, 22, 15, 0.8) 0%, rgba(15, 10, 5, 0.85) 100%),
    url('/images/ui_bg2.jpg') center / 100% 100% no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);

  cursor: pointer;
  transition: all 0.2s ease;
}

.card:hover {
  background: linear-gradient(135deg, rgba(50, 40, 30, 0.95) 0%, rgba(65, 55, 45, 0.95) 100%);
  border-color: rgba(100, 85, 70, 0.8);
  box-shadow: var(--shadow-lg);
}

.card.selected {
  border-color: var(--gold-light);
  box-shadow: 0 0 20px rgba(var(--gold-rgb), 0.4), var(--shadow-lg);
  background: rgba(197, 160, 89, 0.1);
}

/* ========== CHARACTER COMPONENTS ========== */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
}

.character-card {
  background: 
    linear-gradient(180deg, rgba(35, 25, 15, 0.9) 0%, rgba(15, 10, 5, 0.95) 100%),
    url('/images/ui_bg2.jpg') center / 100% 100% no-repeat;
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.character-card:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), 0 0 15px rgba(197, 160, 89, 0.2);
}

.character-card.selected {
  border-color: var(--gold-light);
  background: rgba(197, 160, 89, 0.1);
  box-shadow: 0 0 20px rgba(197, 160, 89, 0.3);
}

.character-card .name {
  font-family: var(--font-title);
  font-size: var(--font-size-lg);
  color: var(--gold-light);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.character-card .info {
  color: var(--ink-dim);
  font-size: var(--font-size-sm);
}

.character-card .level {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--gold-dark);
  color: white;
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: bold;
}

.character-card .delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #722f37;
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.character-card:hover .delete-btn {
  opacity: 1;
}

.character-card .delete-btn:hover {
  background: #a03a3a;
  transform: scale(1.1);
}

.character-avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--gold-dark);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.character-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.create-character-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gold-dark);
  background: rgba(0, 0, 0, 0.2);
  min-height: 180px;
}

.create-character-slot .create-plus {
  font-size: 48px;
  color: var(--gold-dark);
  margin-bottom: var(--space-sm);
}

.create-character-slot:hover {
  border-color: var(--gold);
  background: rgba(197, 160, 89, 0.05);
}

.create-character-slot:hover .create-plus {
  color: var(--gold);
}

/* ========== CHAT COMPONENTS ========== */
.message {
  margin-bottom: 4px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--gold-dark);
  font-size: var(--font-size-sm);
  text-align: left;
  transition: background 0.2s ease;
}

.message:hover {
  background: rgba(255, 255, 255, 0.03);
}

.message .sender {
  font-weight: 600;
  color: var(--gold-light);
  margin-right: 8px;
}

.message .time {
  font-size: 10px;
  color: var(--ink-dark);
  float: right;
}

.message .text {
  color: var(--ink);
  word-wrap: break-word;
}

.message.own {
  border-left-color: #4a9eff;
  background: rgba(74, 158, 255, 0.05);
}

.message.own .sender {
  color: #4a9eff;
}

.message.system {
  border-left-color: var(--gold);
  font-style: italic;
  background: rgba(197, 160, 89, 0.05);
}

/* ========== TAB COMPONENT ========== */
.tabs {
  display: flex;
  background: linear-gradient(180deg, rgba(26,18,12,0.7), rgba(18,12,8,0.7));
  border-bottom: 1px solid rgba(110, 90, 70, 0.35);
  gap: 2px;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: var(--space-sm);
  text-align: center;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  transition: all 0.2s ease;
  color: var(--ink-dim);
}

.tab:hover {
  background: rgba(40, 30, 20, 0.5);
  color: var(--ink);
}

.tab.active {
  border-bottom-color: var(--gold);
  color: var(--gold-light);
  background: rgba(40, 30, 20, 0.5);
}

/* ========== NOTIFICATION ========== */
.notification {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  color: white;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.notification.show {
  opacity: 1;
}

.notification.success {
  background: linear-gradient(45deg, #5a7a4a 0%, #6d8c5a 100%);
}

.notification.error {
  background: linear-gradient(45deg, #722f37 0%, #8b4a47 100%);
}

.notification.info {
  background: linear-gradient(45deg, var(--gold-dark) 0%, var(--gold) 100%);
}

/* ========== LOADING SPINNER ========== */
.loading {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--gold);
  animation: spin 1s ease-in-out infinite;
}

.loading.show {
  display: inline-block;
}

.loading-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

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

/* ========== TABLE COMPONENT ========== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

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

.table th {
  background: rgba(0, 0, 0, 0.3);
  color: var(--gold-light);
  font-weight: 600;
  text-transform: uppercase;
  font-size: var(--font-size-xs);
  letter-spacing: 0.5px;
}

.table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ========== UTILITY CLASSES ========== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.text-gold { color: var(--gold-light); }
.text-dim { color: var(--ink-dim); }
.text-dark { color: var(--ink-dark); }

.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.p-0 { padding: 0; }
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { justify-content: center; align-items: center; }
.flex-between { justify-content: space-between; }
.flex-gap-sm { gap: var(--space-sm); }
.flex-gap-md { gap: var(--space-md); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  
  .panel {
    padding: var(--space-md);
  }
  
  .header h1 {
    font-size: 20px;
  }
  
  .header h2 {
    font-size: var(--font-size-md);
  }
}
