/* CleanPlay Web App - Mobile & Desktop Styling */
:root {
  --bg-primary: #0e0918;
  --bg-card: rgba(28, 20, 44, 0.85);
  --bg-card-border: rgba(142, 102, 230, 0.3);
  --accent-purple: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --text-primary: #f5f3ff;
  --text-secondary: #c4b5fd;
  --text-muted: #8b82a8;
  --success: #10b981;
  --error: #ef4444;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(124, 58, 237, 0.1) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 16px);
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .logo {
  font-size: 26px;
}

.brand h1 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .badge {
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid rgba(139, 92, 246, 0.5);
  color: #ddd6fe;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  text-transform: uppercase;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Input Card */
.input-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.input-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-group input {
  flex: 1 1 240px;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(14, 9, 24, 0.85);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* Buttons */
button, .btn-outline {
  font-family: inherit;
  border-radius: var(--radius-md);
  height: 48px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.4);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: var(--text-secondary);
}

.btn-outline:active {
  background: rgba(139, 92, 246, 0.25);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  height: auto;
  padding: 4px;
}

/* Status message */
.status-msg {
  margin-top: 12px;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-msg.info {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--text-secondary);
}

.status-msg.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Player Card */
.player-card {
  padding: 0;
  overflow: hidden;
  border-color: rgba(139, 92, 246, 0.45);
}

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-loader {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #ddd6fe;
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(139, 92, 246, 0.3);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.player-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.title-row h2 {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.4;
  word-break: break-word;
}

.size-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.control-item select {
  background: #1d152e;
  color: var(--text-primary);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* Playlist Card */
.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.playlist-header h3 {
  font-size: 15px;
  font-weight: 650;
}

.playlist-counter {
  font-size: 12px;
  color: var(--text-muted);
}

.playlist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(14, 9, 24, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.playlist-item:active {
  transform: scale(0.98);
}

.playlist-item.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent-purple);
}

.item-index {
  font-size: 12px;
  color: var(--text-muted);
  width: 22px;
  text-align: center;
}

.playlist-item.active .item-index {
  color: var(--accent-purple);
  font-weight: bold;
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.item-play-icon {
  font-size: 14px;
  color: var(--accent-purple);
  opacity: 0;
  transition: opacity 0.15s;
}

.playlist-item.active .item-play-icon {
  opacity: 1;
}

/* Recents */
.recents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.recents-header h3 {
  font-size: 14px;
  color: var(--text-secondary);
}

.recents-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recents-list li {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.recents-list li:active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

/* Guide Card */
.guide-card h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.guide-steps {
  list-style-position: inside;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.guide-steps strong {
  color: var(--text-primary);
}

/* Footer */
footer {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .app-container {
    gap: 12px;
  }
  .card {
    padding: 14px;
    border-radius: var(--radius-md);
  }
  .input-group input {
    flex: 1 1 100%;
  }
  .input-group button {
    flex: 1;
  }
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .action-buttons {
    width: 100%;
  }
  .action-buttons button, .action-buttons a {
    flex: 1;
  }
}
