/**
 * Styles for WebRTC Remote Control
 */

:root {
  --primary-color: #007bff;
  --danger-color: #dc3545;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --secondary-color: #6c757d;
  --background: #f8f9fa;
  --text-color: #212529;
  --border-color: #dee2e6;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background);
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.container {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  color: var(--primary-color);
  margin-bottom: 10px;
}

header p {
  color: var(--secondary-color);
}

/* ==================== HOST PAGE REDESIGN ==================== */

/* Settings Section (Collapsible) */
.settings-section {
  background: white;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  height: 40px;
  cursor: pointer;
  user-select: none;
}

.settings-label {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  flex: 1;
}

.toggle-arrow {
  font-size: 10px;
  color: #6c757d;
  transition: transform 0.3s;
}

.toggle-arrow.expanded {
  transform: rotate(-180deg);
}

.settings-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.settings-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 12px 20px;
}

/* Main Control Bar */
.main-control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 8px 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  height: 40px;
}

.control-left {
  display: flex;
  gap: 8px;
  flex: 1;
  align-items: center;
}

.control-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Info Bars (Unified Height) */
.info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px;
  height: 32px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  font-size: 12px;
  flex-shrink: 0;
}

.info-label {
  font-weight: 600;
  color: #495057;
  font-size: 13px;
}

.info-value {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 13px;
}

.info-detail {
  color: #6c757d;
  font-size: 11px;
  display: flex;
  gap: 12px;
}

.enc-item {
  color: #495057;
  font-family: 'Courier New', monospace;
}

.enc-item strong {
  color: #212529;
  font-weight: 700;
}

/* Input Styles */
.input-sm {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #ced4da;
  background: white;
  height: 32px;
  flex: 1;
}

.input-compact {
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid #ced4da;
  background: white;
  height: 24px;
  width: 140px;
}

.room-id-input {
  background: #f8f9fa;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  width: 110px;
}

/* Button Styles */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  height: 32px;
}

.btn-primary-compact,
.btn-secondary-compact,
.btn-danger-compact {
  padding: 2px 12px;
  font-size: 12px;
  height: 24px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary-compact {
  background: var(--primary-color);
  color: white;
}

.btn-primary-compact:hover:not(:disabled) {
  background: #0056b3;
}

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

.btn-secondary-compact {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary-compact:hover:not(:disabled) {
  background: #545b62;
}

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

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

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

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

.btn-icon-compact {
  background: none;
  border: none;
  font-size: 14px;
  padding: 0 6px;
  cursor: pointer;
  height: 24px;
  opacity: 0.6;
}

.btn-icon-compact:hover:not(:disabled) {
  opacity: 1;
}

.btn-icon-compact:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Status Text (Colored) */
.status-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary-color);
  background: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

.status-text.connected {
  color: var(--success-color) !important;
}

.status-text.disconnected {
  color: var(--secondary-color) !important;
}

.status-text.active {
  color: var(--success-color) !important;
}

.status-text.inactive {
  color: var(--secondary-color) !important;
}

.status-text.failed {
  color: var(--danger-color) !important;
}

/* Status Badge (Legacy - for client page) */
.status-badge {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  background: var(--secondary-color);
  color: white;
}

.status-badge.connected {
  background: var(--success-color);
}

.status-badge.disconnected {
  background: var(--secondary-color);
}

.status-badge.active {
  background: var(--success-color);
}

.status-badge.inactive {
  background: var(--secondary-color);
}

/* Legacy compatibility - keeping old classes for client page */
.compact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  margin: 0;
  background: white;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.header-center {
  display: flex;
  gap: 10px;
}

.header-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Room Bar (Client) */
.room-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: white;
  flex-shrink: 0;
}

.room-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.room-center {
  display: flex;
  gap: 10px;
}

.room-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

main {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  gap: 0;
  position: relative;
}

/* Expanded mode styles */
body.expanded-mode .settings-section {
  display: none;
}

body.expanded-mode .main-control-bar:first-of-type {
  display: none;
}

body.expanded-mode .info-bar {
  display: none;
}

body.expanded-mode .main-control-bar {
  padding: 4px 10px;
  height: 32px;
}

body.expanded-mode .log-panel {
  display: none;
}

body.expanded-mode .video-container {
  flex: 1;
  height: 100%;
}

section {
  background: white;
  padding: 0;
  margin: 0;
}

h3 {
  margin-bottom: 15px;
  color: #495057;
  padding-bottom: 0;
  font-size: 13px;
  font-weight: 600;
}

/* Control Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.room-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.room-info label {
  font-weight: bold;
  min-width: 80px;
}

.room-info input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
}

/* Buttons */
button {
  padding: 10px 20px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: #0056b3;
}

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

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

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #545b62;
}

/* Status Panel */
.status-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: var(--background);
}

.status-item .label {
  font-weight: bold;
}

.status {
  padding: 2px 10px;
  font-size: 12px;
  font-weight: bold;
}

.status.connected,
.status.active {
  background: var(--success-color);
  color: white;
}

.status.disconnected,
.status.inactive,
.status.disabled {
  background: var(--secondary-color);
  color: white;
}

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

/* Client List */
.client-list ul {
  list-style: none;
  padding: 0;
}

.client-list li {
  padding: 10px;
  background: var(--background);
  margin-bottom: 5px;
}

/* Video Container */
.video-container {
  position: relative;
  background: #000;
  overflow: hidden;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remoteVideo {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: default;
}

.video-overlay.control-enabled {
  cursor: crosshair; /* Show precise cursor for remote control */
}

/* Host cursor overlay - red dot */
.host-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  z-index: 100;
  display: block;
  transform: translate(-6px, -6px); /* Center the dot on the actual position */
  background-color: rgba(255, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5), 0 0 8px rgba(255, 0, 0, 0.6);
}

.placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  color: #888;
  font-size: 18px;
  z-index: 0;
  pointer-events: none;
}

/* Log Panel */
.log-panel {
  flex: 1;
  background: white;
  padding: 10px 20px;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.log-panel h3 {
  font-size: 13px;
  margin-bottom: 8px;
  padding-bottom: 0;
  border: none;
}

.log-output {
  flex: 1;
  overflow-y: auto;
  background: #1a1a1a;
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  padding: 8px;
}

.log-entry {
  margin-bottom: 5px;
}

.log-error {
  color: #ff4444;
}

.log-success {
  color: #44ff44;
}

.log-warning {
  color: #ffaa00;
}

.log-info {
  color: #44aaff;
}

.log-debug {
  color: #888;
}

/* Index Page */
.card-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.card {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
  transition: transform 0.3s;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card h2 {
  color: var(--primary-color);
  margin-bottom: 15px;
}

.card p {
  color: var(--secondary-color);
  margin-bottom: 20px;
}

.card a {
  display: inline-block;
  padding: 12px 30px;
  background: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.3s;
}

.card a:hover {
  background: #0056b3;
}

/* Responsive */
@media (max-width: 768px) {
  .room-info {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    flex-direction: column;
  }

  .card-container {
    grid-template-columns: 1fr;
  }

  .compact-header {
    flex-direction: column;
    gap: 10px;
  }

  .header-left,
  .header-center,
  .header-right {
    width: 100%;
    justify-content: center;
  }
}

/* Idle Mode Overlay */
.idle-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.idle-overlay-content {
  text-align: center;
  color: white;
}

.idle-message {
  font-size: 16px;
  margin-bottom: 20px;
  color: #ffc107;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.btn-wake-up {
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 3px;
  background: #ffc107;
  color: #212529;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-wake-up:hover {
  background: #ffcd39;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.btn-wake-up:active {
  transform: translateY(0);
}

.btn-wake-up:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}
