/* ==========================================
   RemoteLink PWA スタイルシート
   設計書 §6.1, §6.2 に準拠
   ========================================== */

/* リセット */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --border: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* ==========================================
   ログイン画面
   ========================================== */
.login-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
}

.login-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-form {
  width: 100%;
  max-width: 360px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 16px; /* iOSのズーム防止 */
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn:disabled {
  opacity: 0.5;
}

.error-msg {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ==========================================
   ホーム画面（デバイス一覧） - 設計書§6.2
   ========================================== */
.home-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.home-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.home-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.home-header .user-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 6px 12px;
  border-radius: 20px;
}

.device-list {
  flex: 1;
  padding: 0 20px 20px;
  overflow-y: auto;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.device-card:active {
  transform: scale(0.98);
  border-color: var(--accent);
}

.device-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 12px;
}

.device-info {
  flex: 1;
}

.device-name {
  font-size: 15px;
  font-weight: 600;
}

.device-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.device-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.device-status.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.device-status.offline {
  background: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ==========================================
   リモートデスクトップ画面 - 設計書§6.2
   ========================================== */
.remote-screen {
  height: 100%;
  width: 100%;
  background: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remote-screen video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* フローティングメニュー（設計書§6.2） */
.floating-menu-btn {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gradient);
  border: none;
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s;
}

.floating-menu-btn:active {
  transform: scale(0.9);
}

.floating-menu {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  z-index: 999;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.floating-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-primary);
  width: 100%;
  text-align: left;
}

.floating-menu-item:active {
  background: rgba(255, 255, 255, 0.05);
}

.floating-menu-item.danger {
  color: var(--danger);
}

.connection-status-bar {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  padding: 8px 16px;
  font-size: 12px;
  text-align: center;
  z-index: 998;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
}

.hidden { display: none !important; }
