/* Admin Panel Styles */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #06b6d4;
  --light: #f8fafc;
  --dark: #0f172a;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

/* Login Page */
.login-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 28px;
  color: var(--dark);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--gray-500);
  font-size: 14px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
  color: var(--danger);
  background-color: #fee2e2;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-top: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background-color: var(--gray-300);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-block {
  width: 100%;
  padding: 12px;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* Admin Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 18px;
  color: white;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-left: 3px solid var(--primary);
}

.nav-item .icon {
  margin-right: 10px;
  font-size: 16px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info span {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 30px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 24px;
  color: var(--dark);
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 15px;
  color: var(--dark);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
}

.stat-icon {
  font-size: 32px;
  margin-right: 15px;
}

.stat-info h3 {
  font-size: 24px;
  color: var(--dark);
  margin-bottom: 4px;
}

.stat-info p {
  font-size: 13px;
  color: var(--gray-500);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 600;
  text-transform: uppercase;
}

.data-table td {
  font-size: 14px;
  color: var(--gray-700);
}

.data-table tr:hover {
  background: var(--gray-50);
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-indicator.online {
  background-color: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.status-indicator.offline {
  background-color: var(--danger);
}

/* Buckets Grid */
.buckets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.bucket-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.bucket-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.bucket-card h4 {
  font-size: 16px;
  color: var(--dark);
  margin-bottom: 8px;
}

.bucket-card .bucket-stats {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 10px;
}

.bucket-actions {
  margin-top: 15px;
  display: flex;
  gap: 8px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 30px;
  max-width: 500px;
  width: 90%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-500);
}

.modal-close:hover {
  color: var(--dark);
}

.modal h3 {
  margin-bottom: 20px;
  font-size: 18px;
  color: var(--dark);
}

/* Form */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Storage list */
.storage-list {
  font-size: 14px;
}

.storage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.storage-item:last-child {
  border-bottom: none;
}

.storage-name {
  display: flex;
  align-items: center;
}

.storage-name .icon {
  margin-right: 8px;
  font-size: 18px;
}

.storage-size {
  color: var(--gray-500);
  font-size: 13px;
}

.user-list {
  font-size: 14px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.user-item:last-child {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-primary {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.badge-success {
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
}

.badge-danger {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.action-cell {
  white-space: nowrap;
}

.action-cell .btn {
  margin-right: 4px;
}

.action-cell .btn:last-child {
  margin-right: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-readonly {
  background: var(--gray-100);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--dark);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.storage-item-default {
  border-left: 3px solid #ff9800;
  background: linear-gradient(90deg, rgba(255,152,0,0.05) 0%, transparent 100%);
}

/* Background grid view */
.bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 4px 0;
}

.bg-grid-item {
  background: #1a1a2e;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2a2a4a;
  transition: border-color 0.2s;
}

.bg-grid-item:hover {
  border-color: #4a4a8a;
}

.bg-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.bg-thumb:hover {
  transform: scale(1.03);
}

.bg-grid-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  font-size: 12px;
  color: #ccc;
}

.bg-grid-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 6px;
}

/* View toggle buttons */
.view-toggle {
  display: flex;
  gap: 4px;
}

.view-toggle .view-btn.active {
  background: #3a3a6a;
  color: #fff;
  border-color: #5a5a9a;
}

/* Category Panel */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.category-section {
  background: #f8fafc;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #e2e8f0;
}

.category-section h4 {
  font-size: 14px;
  color: #1e293b;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.category-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar-label {
  width: 100px;
  flex-shrink: 0;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
  min-width: 2px;
}

.bar-admin { background: #6366f1; }
.bar-regular { background: #2563eb; }
.bar-enabled { background: #16a34a; }
.bar-disabled { background: #dc2626; }
.bar-character { background: #f59e0b; }
.bar-storage { background: #06b6d4; }
.bar-token { background: #8b5cf6; }

.bar-value {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  color: #64748b;
  font-size: 12px;
}

/* Character card grid view */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 4px 0;
}

.char-grid-item {
  background: #1a1a2e;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2a2a4a;
  transition: border-color 0.2s, transform 0.2s;
}

.char-grid-item:hover {
  border-color: #6a6a9a;
  transform: translateY(-2px);
}

.char-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #12121e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.char-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.char-grid-info {
  padding: 8px 10px;
}

.char-grid-name {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.char-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.char-tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: #2a2a4a;
  color: #aaa;
}

.char-actions {
  display: flex;
  gap: 6px;
  padding: 0 10px 10px;
}

.char-actions .btn {
  flex: 1;
  font-size: 11px;
  padding: 4px 8px;
}

/* Character list view */
.char-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.char-list-item:last-child {
  border-bottom: none;
}

.char-list-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.char-list-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #12121e;
  flex-shrink: 0;
}

.char-list-info {
  flex: 1;
  min-width: 0;
}

.char-list-name {
  font-size: 14px;
  font-weight: 600;
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.char-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.char-list-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
