/**
 * Controller CSS
 * 操作画面用スタイル
 */

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

html,
body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  overflow: hidden;
}

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

/* ======================================
   ヘッダー
====================================== */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 1px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff6b6b;
  animation: blink 1s infinite;
}

.status-indicator.connected {
  background: #51cf66;
  animation: none;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.3;
  }
}

/* ======================================
   メインコンテンツ
====================================== */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  flex: 1;
  overflow: hidden;
}

/* プレビューセクション */
.preview-section {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.preview-section h2 {
  background: #f8f9fa;
  padding: 12px 16px;
  font-size: 16px;
  border-bottom: 1px solid #e9ecef;
  margin: 0;
}

.preview-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #000;
}

#preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.preview-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.preview-loading.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.preview-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin-preview 1s linear infinite;
  margin-bottom: 12px;
}

.preview-loading-text {
  color: white;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
}

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

.preview-info {
  padding: 12px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  font-size: 12px;
  color: #666;
}

/* コントロールセクション */
.control-section {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.control-section h2 {
  background: #f8f9fa;
  padding: 12px 16px;
  font-size: 16px;
  border-bottom: 1px solid #e9ecef;
  margin: 0;
}

.control-section > * {
  padding: 16px;
}

/* 設定パネル */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid #e9ecef;
  padding: 16px;
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-group label {
  min-width: 80px;
  font-weight: 500;
  font-size: 13px;
}

.setting-group select,
.setting-group input[type='color'] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.setting-group input[type='color'] {
  cursor: color-picker;
  height: 36px;
  padding: 2px;
}

/* ボタン */
.btn-settings {
  background: #4dabf7;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-settings:hover {
  background: #339af0;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(77, 171, 247, 0.3);
}

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

/* モーションボタン */
.motion-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  flex: 1;
  overflow-y: auto;
}

.motion-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 14px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-align: left;
}

.motion-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.motion-button:active {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.motion-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* コントロールアクション */
.control-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #e9ecef;
}

.btn-secondary {
  flex: 1;
  background: #e9ecef;
  color: #333;
  border: 1px solid #ccc;
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #dee2e6;
  border-color: #aaa;
}

/* ======================================
   ログセクション
====================================== */
.log-section {
  background: white;
  border-top: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  max-height: 200px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.log-header h3 {
  font-size: 14px;
  margin: 0;
}

.btn-small {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.btn-small:hover {
  background: #e9ecef;
  color: #333;
}

#log-content {
  overflow-y: auto;
  padding: 12px 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #666;
  line-height: 1.4;
}

.log-item {
  margin-bottom: 8px;
  padding: 4px;
  border-left: 3px solid #ccc;
  padding-left: 8px;
}

.log-item.info {
  border-left-color: #4dabf7;
  color: #1971c2;
}

.log-item.warn {
  border-left-color: #ffa94d;
  color: #e67700;
}

.log-item.error {
  border-left-color: #ff8787;
  color: #c92a2a;
}

.log-timestamp {
  color: #aaa;
  font-size: 11px;
  margin-right: 8px;
}

/* ======================================
   レスポンシブ
====================================== */
@media (max-width: 1400px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
  }

  .main-content {
    padding: 12px;
    gap: 12px;
  }

  .log-section {
    display: none;
  }
}

/* スクロールバーカスタマイズ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #b0b0b0;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #888;
}
/* ======================================
   認証モーダル
====================================== */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.auth-modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-modal-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-modal-header h2 {
  font-size: 28px;
  color: #667eea;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.auth-modal-header p {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.form-group input {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-error {
  color: #e74c3c;
  font-size: 12px;
  padding: 8px 12px;
  background: #fadbd8;
  border-radius: 4px;
  display: none;
  min-height: 20px;
}

.auth-error.show {
  display: block;
}

.auth-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.auth-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.auth-button:active {
  transform: translateY(0);
}

.auth-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ======================================
   モバイルレスポンシブ対応
====================================== */
@media (max-width: 768px) {
  /* ヘッダー */
  .header {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .header h1 {
    font-size: 22px;
  }

  .connection-status {
    font-size: 12px;
  }

  /* メインコンテンツ */
  .main-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  /* プレビューセクション */
  .preview-section {
    min-height: 300px;
    max-height: 40vh;
  }

  .preview-section h2 {
    padding: 10px 12px;
    font-size: 14px;
  }

  /* コントロールセクション */
  .control-section {
    flex: 1;
  }

  .control-section h2 {
    padding: 10px 12px;
    font-size: 14px;
  }

  .control-section > * {
    padding: 12px;
  }

  /* 設定パネル */
  .settings-panel {
    gap: 10px;
    padding: 12px;
  }

  .setting-group {
    gap: 8px;
  }

  .setting-group label {
    min-width: auto;
    font-size: 12px;
  }

  .setting-group select,
  .setting-group input[type='color'] {
    font-size: 12px;
    padding: 6px;
  }

  .btn-settings {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* モーションボタン */
  .motion-buttons {
    gap: 6px;
    margin-top: 6px;
  }

  .motion-button {
    padding: 12px 14px;
    font-size: 13px;
  }

  /* 制御ボタン */
  .control-actions {
    gap: 10px;
    padding: 12px;
  }

  .btn-secondary {
    font-size: 12px;
    padding: 8px 12px;
  }

  /* ログセクション */
  .log-section {
    max-height: 200px;
  }

  .log-header {
    padding: 10px 12px;
  }

  .log-header h3 {
    font-size: 13px;
  }

  .log-content {
    max-height: 150px;
    font-size: 11px;
  }

  .log-item {
    padding: 4px 6px;
  }

  .log-timestamp {
    font-size: 10px;
  }

  /* 認証モーダル */
  .auth-modal-content {
    padding: 30px 20px;
    width: 90%;
    max-width: 100%;
  }

  .auth-modal-header h2 {
    font-size: 22px;
  }

  .auth-modal-header p {
    font-size: 12px;
  }

  .form-group input {
    padding: 10px;
    font-size: 12px;
  }

  .auth-button {
    padding: 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  /* ヘッダー */
  .header {
    padding: 12px;
  }

  .header h1 {
    font-size: 18px;
  }

  .connection-status {
    font-size: 11px;
    padding: 6px 12px;
  }

  .status-indicator {
    width: 10px;
    height: 10px;
  }

  /* メインコンテンツ */
  .main-content {
    gap: 10px;
    padding: 10px;
  }

  /* プレビューセクション */
  .preview-section {
    min-height: 250px;
    max-height: 35vh;
  }

  /* モーションボタン */
  .motion-button {
    padding: 16px 14px;
    font-size: 16px;
    font-weight: 600;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 制御ボタン */
  .control-actions {
    flex-direction: column;
    gap: 8px;
  }

  .btn-secondary {
    width: 100%;
  }

  /* ログセクション */
  .log-section {
    max-height: 150px;
  }

  .log-content {
    max-height: 120px;
    font-size: 10px;
  }
}