* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  text-align: center;
  padding: 40px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #fff;
}

.header p {
  color: rgba(255, 255, 255, 0.6);
}

/* Cards */
.card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: #fff;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

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

.btn-primary {
  background: #4CAF50;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #45a049;
}

.btn-danger {
  background: #f44336;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #da190b;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.8);
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: #4CAF50;
}

/* Status */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-live {
  background: rgba(76, 175, 80, 0.2);
  color: #4CAF50;
}

.status-offline {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
}

.status-waiting {
  background: rgba(255, 193, 7, 0.2);
  color: #FFC107;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-live .status-dot {
  background: #4CAF50;
}

.status-offline .status-dot {
  background: #f44336;
}

.status-waiting .status-dot {
  background: #FFC107;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Video Container */
.video-container {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  touch-action: none;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  touch-action: none;
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(255, 255, 255, 0.5);
}

.video-placeholder svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Viewer List */
.viewer-list {
  list-style: none;
}

.viewer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  margin-bottom: 8px;
}

.viewer-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viewer-ip {
  font-weight: 500;
  color: #fff;
}

.viewer-location {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
}

.viewer-actions {
  display: flex;
  gap: 8px;
}

.empty-list {
  text-align: center;
  padding: 24px;
  color: rgba(255, 255, 255, 0.4);
}

/* Login Page */
.login-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 20px;
}

.login-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
}

.login-card p {
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 24px;
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.alert-success {
  background: rgba(76, 175, 80, 0.2);
  color: #4CAF50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.alert-info {
  background: rgba(33, 150, 243, 0.2);
  color: #2196F3;
  border: 1px solid rgba(33, 150, 243, 0.3);
}

/* Grid */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Fullscreen button */
.fullscreen-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.fullscreen-btn svg {
  width: 24px;
  height: 24px;
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Center content */
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Preview */
.preview-container {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.preview-container video {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.preview-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
}

/* ==================== MOBILE RESPONSIVE ==================== */

/* Viewer page - mobile optimized */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header {
    padding: 20px 10px;
    margin-bottom: 15px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .header p {
    font-size: 0.875rem;
  }

  .card {
    padding: 16px;
    border-radius: 8px;
  }

  /* Video container - full width on mobile */
  .video-container {
    border-radius: 8px;
    /* Allow video to be taller on mobile for better viewing */
    aspect-ratio: auto;
    min-height: 200px;
  }

  .video-container video {
    max-height: 70vh;
  }

  .video-placeholder {
    min-height: 200px;
    padding: 20px;
  }

  .video-placeholder svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
  }

  /* Buttons - larger touch targets */
  .btn {
    padding: 14px 28px;
    font-size: 1rem;
    width: 100%;
    text-align: center;
  }

  .btn-small {
    padding: 10px 16px;
    font-size: 0.875rem;
    width: auto;
  }

  /* Fullscreen button - larger on mobile */
  .fullscreen-btn {
    bottom: 12px;
    right: 12px;
    padding: 12px;
  }

  .fullscreen-btn svg {
    width: 28px;
    height: 28px;
  }

  /* Status badge */
  .status {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  /* Center content area */
  .center {
    padding: 24px 16px;
  }

  .center p {
    font-size: 0.9rem;
  }

  /* Spinner */
  .spinner {
    width: 32px;
    height: 32px;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.25rem;
  }

  .video-container {
    border-radius: 0;
    margin: 0 -16px;
    width: calc(100% + 32px);
  }

  .card {
    border-radius: 0;
    margin: 0 -10px;
    width: calc(100% + 20px);
    border-left: none;
    border-right: none;
  }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .header {
    padding: 10px;
    margin-bottom: 10px;
  }

  .header h1 {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }

  .header p {
    display: none;
  }

  .video-container {
    aspect-ratio: auto;
    height: 60vh;
  }

  .video-container video {
    max-height: 60vh;
  }

  .center {
    padding: 16px;
  }
}

/* Fullscreen video styles */
.video-container:fullscreen {
  background: #000;
  border-radius: 0;
  touch-action: none;
}

.video-container:fullscreen video {
  max-height: 100vh;
  height: 100vh;
  touch-action: none;
}

.video-container:fullscreen .fullscreen-btn {
  bottom: 20px;
  right: 20px;
}

/* Mobile video wrapper fullscreen */
.mobile-video-wrapper:fullscreen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.mobile-video-wrapper:fullscreen .mobile-overlay {
  display: none;
}

.mobile-video-wrapper:fullscreen .mobile-controls {
  display: none;
}

/* Webkit prefix */
.mobile-video-wrapper:-webkit-full-screen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-video-wrapper:-webkit-full-screen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mobile-video-wrapper:-webkit-full-screen .mobile-overlay {
  display: none;
}

.mobile-video-wrapper:-webkit-full-screen .mobile-controls {
  display: none;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .btn:active {
    transform: scale(0.98);
  }

  .fullscreen-btn:active {
    background: rgba(0, 0, 0, 0.8);
  }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  .container {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .video-container:fullscreen .fullscreen-btn {
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
  }
}

/* ==================== MOBILE FULLSCREEN LAYOUT ==================== */

.mobile-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 9999;
}

.mobile-video-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.mobile-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
}

/* Mobile overlay - ortada mesaj goster */
.mobile-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
}

.mobile-overlay.hidden {
  display: none;
}

.mobile-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: #fff;
}

.mobile-state p {
  font-size: 1.1rem;
  margin-bottom: 24px;
  color: rgba(255, 255, 255, 0.8);
}

.mobile-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.mobile-icon svg {
  width: 40px;
  height: 40px;
  stroke: rgba(255, 255, 255, 0.6);
}

.mobile-icon.live {
  background: rgba(76, 175, 80, 0.2);
}

.mobile-icon.live svg {
  stroke: #4CAF50;
}

.mobile-icon.error {
  background: rgba(244, 67, 54, 0.2);
}

.mobile-icon.error svg {
  stroke: #f44336;
}

.mobile-btn {
  padding: 16px 48px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transition: all 0.2s;
}

.mobile-btn:active {
  transform: scale(0.96);
}

.mobile-btn.primary {
  background: #4CAF50;
  color: #fff;
}

.mobile-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}

/* Mobile controls - izlerken */
.mobile-controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
  padding-top: env(safe-area-inset-top, 16px);
}

.mobile-controls.hidden {
  display: none;
}

.mobile-live-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(244, 67, 54, 0.9);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.mobile-fullscreen-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-fullscreen-btn svg {
  width: 24px;
  height: 24px;
}

/* Mobile: Desktop'u gizle, mobile'i goster */
@media (max-width: 768px) {
  #desktop-layout {
    display: none !important;
  }

  #mobile-layout {
    display: block !important;
  }

  #mobile-layout.hidden {
    display: block !important;
  }
}

/* Desktop: Mobile'i gizle */
@media (min-width: 769px) {
  #mobile-layout {
    display: none !important;
  }
}
