/**
 * Shared CSS Variables and Component Styles
 *
 * This file defines CSS custom properties and base styles for shared components.
 * Each theme (owner/user) should define their own values for these variables.
 */

/* =========================================
   CSS Custom Properties
   ========================================= */

:root {
  /* These are default values - override in theme-specific CSS */

  /* Text colors */
  --color-text-primary: #ffffff;
  --color-text-secondary: #9ca3af;
  --color-text-muted: #6b7280;
  --color-text-error: #ef4444;
  --color-text-success: #22c55e;
  --color-text-warning: #f59e0b;
  --color-text-info: #3b82f6;

  /* Background colors */
  --color-bg-primary: #111827;
  --color-bg-secondary: #1f2937;
  --color-bg-tertiary: #374151;
  --color-bg-hover: #374151;

  /* Border colors */
  --color-border: #374151;
  --color-border-focus: #6366f1;

  /* Accent/action colors */
  --color-accent: #6366f1;
  --color-accent-hover: #4f46e5;
  --color-accent-text: #ffffff;

  /* Status colors */
  --color-status-active: #22c55e;
  --color-status-suspended: #f59e0b;
  --color-status-banned: #ef4444;
  --color-status-pending: #8b5cf6;
  --color-status-inactive: #6b7280;

  /* Role colors */
  --color-role-owner: #f59e0b;
  --color-role-admin: #ef4444;
  --color-role-moderator: #8b5cf6;
  --color-role-member: #3b82f6;
  --color-role-guest: #6b7280;

  /* Privacy colors */
  --color-privacy-public: #22c55e;
  --color-privacy-unlisted: #f59e0b;
  --color-privacy-private: #ef4444;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;

  /* Font sizes */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-base: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* Transitions */
  --transition-fast: 150ms;
  --transition-base: 200ms;
  --transition-slow: 300ms;
}

/* =========================================
   Base Styles
   ========================================= */

* {
  box-sizing: border-box;
}

/* =========================================
   Button Styles
   ========================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
}

.btn:disabled,
.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-accent-text);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-accent-hover);
}

.btn-secondary {
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-bg-hover);
}

.btn-danger {
  background-color: var(--color-status-banned);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-warning {
  background-color: var(--color-status-suspended);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  opacity: 0.9;
}

/* =========================================
   Form Styles
   ========================================= */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.form-row > .form-group {
  flex: 1;
  min-width: 200px;
}

.form-label {
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text-primary);
}

.required-mark {
  color: var(--color-text-error);
  margin-left: var(--spacing-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

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

.form-color {
  width: 100px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-tertiary);
}

.form-help {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  cursor: pointer;
}

.form-checkbox {
  width: 1rem;
  height: 1rem;
  margin-top: 2px;
  accent-color: var(--color-accent);
}

.checkbox-text {
  display: flex;
  flex-direction: column;
  color: var(--color-text-primary);
}

.checkbox-description {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
}

.form-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.search-box {
  display: flex;
  gap: var(--spacing-sm);
}

.search-input {
  flex: 1;
}

/* =========================================
   Card Styles
   ========================================= */

.card {
  background-color: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: var(--font-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-lg);
}

/* =========================================
   Page Header Styles
   ========================================= */

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.page-header-text {
  flex: 1;
}

.page-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: var(--font-base);
  color: var(--color-text-secondary);
  margin: var(--spacing-xs) 0 0 0;
}

.page-header-actions {
  display: flex;
  gap: var(--spacing-sm);
}

/* =========================================
   Alert Styles
   ========================================= */

.alert {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.alert p {
  margin: 0;
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--color-text-error);
  color: var(--color-text-error);
}

.alert-success {
  background-color: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--color-text-success);
  color: var(--color-text-success);
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--color-text-warning);
  color: var(--color-text-warning);
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--color-text-info);
  color: var(--color-text-info);
}

/* =========================================
   Badge Styles
   ========================================= */

.status-badge,
.role-badge,
.privacy-badge,
.badge,
.nsfw-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

/* Status badges */
.status-active {
  background-color: rgba(34, 197, 94, 0.2);
  color: var(--color-status-active);
}

.status-suspended {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--color-status-suspended);
}

.status-banned {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-status-banned);
}

.status-pending {
  background-color: rgba(139, 92, 246, 0.2);
  color: var(--color-status-pending);
}

.status-inactive {
  background-color: rgba(107, 114, 128, 0.2);
  color: var(--color-status-inactive);
}

/* Role badges */
.role-owner {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--color-role-owner);
}

.role-admin {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-role-admin);
}

.role-moderator {
  background-color: rgba(139, 92, 246, 0.2);
  color: var(--color-role-moderator);
}

.role-member {
  background-color: rgba(59, 130, 246, 0.2);
  color: var(--color-role-member);
}

.role-guest {
  background-color: rgba(107, 114, 128, 0.2);
  color: var(--color-role-guest);
}

/* Privacy badges */
.privacy-public {
  background-color: rgba(34, 197, 94, 0.2);
  color: var(--color-privacy-public);
}

.privacy-unlisted {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--color-privacy-unlisted);
}

.privacy-private {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-privacy-private);
}

/* Generic badges */
.badge-primary {
  background-color: rgba(99, 102, 241, 0.2);
  color: var(--color-accent);
}

.badge-secondary {
  background-color: rgba(107, 114, 128, 0.2);
  color: var(--color-text-secondary);
}

.badge-success {
  background-color: rgba(34, 197, 94, 0.2);
  color: var(--color-text-success);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.2);
  color: var(--color-text-warning);
}

.badge-error {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-text-error);
}

.nsfw-badge {
  background-color: rgba(239, 68, 68, 0.2);
  color: var(--color-status-banned);
  text-transform: uppercase;
}

/* =========================================
   Table Styles
   ========================================= */

.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

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

.data-table th {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  background-color: var(--color-bg-tertiary);
}

.data-table td {
  font-size: var(--font-sm);
  color: var(--color-text-primary);
}

.data-table tbody tr:hover {
  background-color: var(--color-bg-hover);
}

.table-row-clickable {
  cursor: pointer;
}

.table-link {
  color: var(--color-accent);
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.pagination-info {
  color: var(--color-text-secondary);
  font-size: var(--font-sm);
}

/* =========================================
   Modal Styles
   ========================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background-color: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 28rem;
  width: calc(100% - 2rem);
  margin: var(--spacing-md);
  padding: var(--spacing-lg);
  border: 1px solid var(--color-border);
}

.modal-content-large {
  max-width: 42rem;
}

.modal-close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  padding: var(--spacing-xs);
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-text-primary);
}

.modal-close-icon {
  width: 1.5rem;
  height: 1.5rem;
}

.modal-body {
  text-align: center;
}

.modal-title {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 var(--spacing-md) 0;
}

.modal-message {
  color: var(--color-text-secondary);
  margin: 0 0 var(--spacing-lg) 0;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

@media (min-width: 640px) {
  .modal-actions {
    flex-direction: row;
    justify-content: center;
  }
}

.modal-actions-center {
  justify-content: center;
}

/* =========================================
   Admin Layout Styles
   ========================================= */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 16rem;
  background-color: var(--color-bg-primary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.admin-content {
  flex: 1;
  margin-left: 16rem;
  padding: var(--spacing-xl);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
}

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  text-decoration: none;
  display: block;
}

.sidebar-brand:hover {
  color: var(--color-accent);
}

.sidebar-subtitle {
  font-size: var(--font-sm);
  color: var(--color-text-muted);
  display: block;
  margin-top: var(--spacing-xs);
}

.sidebar-nav {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
}

.nav-section {
  margin-top: var(--spacing-lg);
}

.nav-section-title {
  display: block;
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--spacing-sm) var(--spacing-md);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  margin-bottom: var(--spacing-xs);
}

.nav-item:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.nav-item-active {
  background-color: var(--color-accent);
  color: var(--color-accent-text);
}

.nav-item-active:hover {
  background-color: var(--color-accent-hover);
  color: var(--color-accent-text);
}

.nav-icon {
  width: 1.25rem;
  height: 1.25rem;
}

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

.sidebar-link {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--font-sm);
  text-align: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text-primary);
}

/* =========================================
   Detail Grid Styles
   ========================================= */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--spacing-md);
}

.detail-item {
  padding: var(--spacing-sm);
}

.detail-label {
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-xs);
}

.detail-value {
  color: var(--color-text-primary);
}

/* =========================================
   Empty State Styles
   ========================================= */

.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--color-text-muted);
}

.empty-state p {
  margin-bottom: var(--spacing-md);
}

/* =========================================
   Centered Layout Styles
   ========================================= */

.centered-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background-color: var(--color-bg-primary);
}

/* =========================================
   Loading Spinner Styles
   ========================================= */

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xl);
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-message {
  color: var(--color-text-muted);
  font-size: var(--font-sm);
}

/* =========================================
   Utility Classes
   ========================================= */

.mt-4 {
  margin-top: var(--spacing-md);
}

.mb-4 {
  margin-bottom: var(--spacing-md);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-success {
  color: var(--color-text-success);
}

.text-error {
  color: var(--color-text-error);
}
