/* Windows 11 Fluent Design System - Unified App */
:root {
  --accent-color: #0078d4;
  --accent-hover: #106ebe;
  --accent-active: #005a9e;
  --success-color: #107c10;
  --success-hover: #0e6b0e;
  --error-color: #d13438;
  --warning-color: #ffb900;
  --bg-color: #f3f3f3;
  --bg-secondary: #ffffff;
  --bg-tertiary: #fafafa;
  --text-primary: #1a1a1a;
  --text-secondary: #5c5c5c;
  --text-muted: #8a8a8a;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-radius: 8px;
  --border-radius-sm: 4px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-color);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  -webkit-app-region: drag;
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-actions {
  -webkit-app-region: no-drag;
}

.language-select {
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  outline: none;
}

.language-select:focus {
  border-color: var(--accent-color);
}

/* Main Content */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Panel - 60% */
.left-panel {
  flex: 0 0 60%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
}

/* Right Panel - 40% */
.right-panel {
  flex: 0 0 40%;
  padding: 20px;
  background: var(--bg-tertiary);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Sections */
.form-section,
.log-section,
.screenshot-section {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

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

.log-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screenshot-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screenshot-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.screenshot-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
}

.screenshot-label {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--accent-color);
  font-weight: 600;
}

.screenshot-buttons {
  display: flex;
  gap: 6px;
}

.btn-debug {
  background: rgba(107, 33, 168, 0.1);
  border: 1px solid rgba(107, 33, 168, 0.3);
  color: #6b21a8;
  font-size: 11px;
  padding: 4px 10px;
}

.btn-debug:hover {
  background: #6b21a8;
  color: white;
  border-color: #6b21a8;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

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

.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  outline: none;
  transition: all 0.15s ease;
}

.form-input:hover {
  border-color: rgba(0, 0, 0, 0.15);
}

.form-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
  background: white;
}

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

.form-input:disabled {
  background: var(--bg-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Password Input Wrapper with Toggle Button */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper .form-input {
  padding-right: 40px;
}

.btn-toggle-password {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--border-radius-sm);
  transition: all 0.15s ease;
}

.btn-toggle-password:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.05);
}

.btn-toggle-password:focus {
  outline: none;
}

.btn-toggle-password:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-color);
}

.btn-toggle-password svg {
  width: 18px;
  height: 18px;
}

/* MFA Group Animation */
.mfa-group {
  animation: slideDown 0.2s ease-out;
}

.btn-small {
  padding: 8px 12px;
  font-size: 12px;
  min-width: auto;
}

.btn-copy {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-copy:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-copy.copied {
  background: var(--success-color);
  color: white;
  border-color: var(--success-color);
}

.btn-tiny {
  padding: 4px 6px;
  font-size: 11px;
  min-width: auto;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-tiny svg {
  width: 14px;
  height: 14px;
}

/* Section header with button */
.section-header-with-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header-with-button .section-title {
  margin-bottom: 0;
}

/* Device ID Banner */
.device-id-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  animation: slideDown 0.2s ease-out;
}

.device-id-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.device-id-value {
  flex: 1;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  color: var(--accent-color);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Buttons */
.button-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.browser-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-family);
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.1s ease;
  min-width: 100px;
}

.btn:focus {
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-color), 0 0 0 4px var(--accent-color);
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
  transform: scale(0.98);
}

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

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

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

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
}

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

.btn-cancel:hover:not(:disabled) {
  background: #c42b2f;
}

/* Log Container */
.log-container {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  padding: 12px;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-color);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-emoji {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.log-message {
  flex: 1;
  word-break: break-word;
  color: var(--text-secondary);
}

.log-entry.log-error .log-message {
  color: var(--error-color);
}

.log-entry.log-success .log-message {
  color: var(--success-color);
}

/* Screenshot Container */
.screenshot-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  min-height: 0;
}

.screenshot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}

.screenshot-placeholder svg {
  opacity: 0.5;
}

.screenshot-placeholder p {
  font-size: 13px;
}

.screenshot-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
}

.screenshot-image:hover {
  opacity: 0.95;
}

/* Thumbnails Gallery - Horizontal */
.thumbnails-container {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  flex-shrink: 0;
}

.thumbnail-item {
  flex-shrink: 0;
  width: 60px;
  height: 45px;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  background: var(--bg-color);
}

.thumbnail-item:hover {
  border-color: var(--accent-color);
  transform: scale(1.05);
}

.thumbnail-item.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.3);
}

.thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-label {
  display: none;
}

/* Footer */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  padding-bottom: 40px; /* Account for copyright bar */
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.footer-buttons {
  display: flex;
  gap: 12px;
}

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

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-indicator.active {
  background: var(--warning-color);
  animation: pulse 1.5s infinite;
}

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

.status-indicator.error {
  background: var(--error-color);
}

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

.status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Error Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}

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

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 24px;
  min-width: 320px;
  max-width: 450px;
  box-shadow: var(--shadow-md), 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--error-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 20px 0;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--error-color);
}

.modal-close {
  width: 100%;
}

/* Debug Modal */
.modal-debug {
  min-width: 500px;
  max-width: 700px;
}

.modal-icon-debug {
  background: #6b21a8;
}

.debug-content {
  max-height: 400px;
  overflow-y: auto;
}

.debug-section {
  margin-bottom: 16px;
}

.debug-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 6px 0;
  text-transform: uppercase;
}

.debug-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.debug-section-header h4 {
  margin: 0;
}

.debug-section pre {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 10px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
  max-height: 100px;
  overflow-y: auto;
}

/* About Modal */
.modal-about {
  min-width: 400px;
  max-width: 500px;
}

.modal-icon-about {
  background: var(--accent-color);
}

.about-content {
  margin-bottom: 20px;
}

.about-version {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}

.about-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 16px 0;
}

.about-section {
  margin-bottom: 16px;
}

.about-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.about-section ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.about-section li {
  margin-bottom: 4px;
}

.about-section p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.about-link {
  color: var(--accent-color);
  text-decoration: none;
}

.about-link:hover {
  text-decoration: underline;
}

/* Copyright Bar */
.copyright-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 100;
}

.copyright-bar:hover {
  background: var(--bg-tertiary);
  color: var(--accent-color);
}

/* Responsive */
@media (max-width: 900px) {
  .app-main {
    flex-direction: column;
  }

  .left-panel,
  .right-panel {
    flex: none;
    width: 100%;
    border-right: none;
  }

  .left-panel {
    border-bottom: 1px solid var(--border-color);
  }
}
