/*
 * Application styles
 *
 *= require bubbla/style/colors
 *= require bubbla/style/application
 *= require bubbla/style/typography
 *= require bubbla/style/buttons
 *= require bubbla/style/button-colors
 *= require bubbla/style/forms
 *= require bubbla/style/tables
 *= require bubbla/style/cards
 *= require bubbla/style/modal
 *= require bubbla/style/main-menu
 */

/* Application-specific styles */
:root {
  /* Pink color scheme */
  --color-primary: #ec4899;
  --color-primary-hover: #db2777;
  --color-primary-dim: rgba(236, 72, 153, 0.15);
  --color-surface: #1f1a1d;
  --color-background: #0f0a0c;
  --color-border: #3d2a33;
  --color-text: #f5e6eb;
  --color-text-secondary: #a78b95;

  --color-seeders: #22c55e;
  --color-leechers: #ef4444;
  --color-warning: #f59e0b;
  --color-success: #22c55e;
  --color-success-bg: #052e1a;
  --color-error: #ef4444;
  --color-error-bg: #2a0a0a;

  --sidebar-width: 220px;
  --topbar-height: 56px;
}

body {
  background: var(--color-background);
  color: var(--color-text);
  margin: 0;
  padding: 0;
}

/* Hidden checkbox for sidebar toggle */
.sidebar-toggle-checkbox {
  display: none;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s ease;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--color-text);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.25rem;
}

.brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.5rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-right: 3px solid transparent;
  margin: 0.125rem 0;
}

.sidebar-nav .nav-link:hover,
.sidebar-footer .nav-link:hover {
  color: var(--color-text);
  background: var(--color-primary-dim);
}

.sidebar-nav .nav-link.active {
  color: var(--color-primary);
  background: var(--color-primary-dim);
  border-right-color: var(--color-primary);
}

.nav-icon {
  font-size: 1.125rem;
  width: 1.5rem;
  text-align: center;
  opacity: 0.8;
}

.nav-text {
  font-size: 0.9375rem;
}

.nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.75rem 1.5rem;
}

.admin-link {
  color: var(--color-warning) !important;
}

.admin-link:hover {
  color: var(--color-warning) !important;
  background: rgba(245, 158, 11, 0.1) !important;
}

.admin-link.active {
  color: var(--color-warning) !important;
  background: rgba(245, 158, 11, 0.15) !important;
  border-right-color: var(--color-warning) !important;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
}

.sidebar-attribution {
  padding: 1rem 1.5rem;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  opacity: 0.6;
}

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  cursor: pointer;
}

/* Main wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar (mobile only by default, but can show on desktop) */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  align-items: center;
  gap: 1rem;
  z-index: 100;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hamburger {
  position: relative;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: background 0.2s;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.2s;
}

.hamburger::before {
  top: -6px;
}

.hamburger::after {
  top: 6px;
}

.topbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar-overlay {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .topbar {
    display: flex;
  }

  .main-content {
    padding: 1.5rem;
  }
}

/* Flash Messages */
.flash {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.flash-notice {
  background: var(--color-success-bg, #064e3b);
  color: var(--color-success, #22c55e);
  border: 1px solid var(--color-success, #22c55e);
}

.flash-alert {
  background: var(--color-error-bg, #450a0a);
  color: var(--color-error, #ef4444);
  border: 1px solid var(--color-error, #ef4444);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0;
}

/* Torrents Table */
.torrents-table {
  width: 100%;
  border-collapse: collapse;
}

.torrents-table th,
.torrents-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border, #2a2a4e);
}

.torrents-table th {
  background: var(--color-surface, #1a1a2e);
  font-weight: 600;
}

.torrents-table tbody tr:hover {
  background: var(--color-surface, rgba(99, 102, 241, 0.1));
}

.name-cell a {
  color: var(--color-primary, #6366f1);
  text-decoration: none;
  font-weight: 500;
}

.name-cell a:hover {
  text-decoration: underline;
}

.torrent-desc {
  color: var(--color-text-secondary, #94a3b8);
  font-size: 0.875rem;
  margin: 0.25rem 0 0 0;
}

.seeders {
  color: var(--color-seeders);
  font-weight: bold;
}

.leechers {
  color: var(--color-leechers);
  font-weight: bold;
}

/* Category Tags */
.category-tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--color-surface, #2a2a4e);
}

.category-tag.movies { background: #7c3aed; color: white; }
.category-tag.tv { background: #2563eb; color: white; }
.category-tag.music { background: #059669; color: white; }
.category-tag.games { background: #dc2626; color: white; }
.category-tag.software { background: #ea580c; color: white; }
.category-tag.other { background: #64748b; color: white; }

/* Filters */
.filters {
  margin-bottom: 2rem;
}

.filter-form {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  flex: 1;
  min-width: 150px;
}

.search-input,
.category-select,
.sort-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border, #2a2a4e);
  border-radius: 0.375rem;
  background: var(--color-background, #0f0f23);
  color: var(--color-text, #e2e8f0);
}

/* Torrent Detail */
.torrent-detail {
  max-width: 1000px;
}

.torrent-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-secondary, #94a3b8);
}

.meta-item .value {
  font-weight: 500;
}

.meta-item .monospace {
  font-family: monospace;
  font-size: 0.875rem;
  word-break: break-all;
}

.torrent-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stat {
  text-align: center;
  padding: 1rem 2rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: bold;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #94a3b8);
}

.torrent-description {
  margin-bottom: 2rem;
}

.description-content {
  padding: 1rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
}

/* Forms */
.upload-form,
.edit-form {
  max-width: 600px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input[type="file"],
.form-group input[type="text"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border, #2a2a4e);
  border-radius: 0.375rem;
  background: var(--color-background, #0f0f23);
  color: var(--color-text, #e2e8f0);
}

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

.help-text {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #94a3b8);
  margin-top: 0.25rem;
}

.static-value {
  padding: 0.5rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.375rem;
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--color-primary, #6366f1);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-hover, #4f46e5);
}

.btn-secondary {
  background: var(--color-surface, #2a2a4e);
  color: var(--color-text, #e2e8f0);
}

.btn-danger {
  background: var(--color-error, #ef4444);
  color: white;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Dashboard */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dashboard-card {
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

.dashboard-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--color-text-secondary, #94a3b8);
}

.dashboard-card .value {
  font-size: 2rem;
  font-weight: bold;
}

.ratio-good { color: var(--color-seeders); }
.ratio-warning { color: #f59e0b; }
.ratio-bad { color: var(--color-leechers); }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--color-text-secondary, #94a3b8);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}

.pagination a,
.pagination span {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  text-decoration: none;
  color: var(--color-text, #e2e8f0);
  background: var(--color-surface, #1a1a2e);
}

.pagination a:hover {
  background: var(--color-primary, #6366f1);
}

.pagination .current {
  background: var(--color-primary, #6366f1);
  color: white;
}


/* Peers table */
.peers-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.peers-table th,
.peers-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border, #2a2a4e);
}

/* Settings page */
.settings-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
}

.settings-section h2 {
  margin-top: 0;
}

.passkey-display {
  font-family: monospace;
  padding: 0.5rem;
  background: var(--color-background, #0f0f23);
  border-radius: 0.375rem;
  margin: 0.5rem 0;
}

.warning-text {
  color: var(--color-error, #ef4444);
  font-size: 0.875rem;
}

/* Tags */
.tag-fields {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
}

.tag-fields h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.torrent-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--color-surface, #1a1a2e);
  border-radius: 0.5rem;
}

.tag-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag-kind {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-secondary, #94a3b8);
  font-weight: 600;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--color-primary, #ec4899);
  color: white;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Inline tags in torrent list */
.torrent-tags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.tag-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: rgba(236, 72, 153, 0.2);
  color: var(--color-primary, #ec4899);
  border-radius: 0.25rem;
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
}

/* Home page hero */
.hero {
  text-align: center;
  padding: 4rem 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.hero .tagline {
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  margin-bottom: 2rem;
}

.btn-large {
  padding: 0.875rem 2rem;
  font-size: 1.125rem;
}

.view-all {
  text-align: center;
  margin-top: 1.5rem;
}

.view-all a {
  color: var(--color-primary);
}

/* Admin pages */
.admin-page h1 {
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.admin-nav {
  margin-bottom: 2rem;
}

.admin-section {
  margin-top: 2.5rem;
}

.admin-section h2 {
  margin-bottom: 1rem;
}
