/* CSS Variables */
:root {
  --primary-color: #2b579a;
  --primary-hover: #1d4084;
  --success-color: #107c10;
  --warning-color: #ff8c00;
  --error-color: #d13438;
  --background-color: #f3f2f1;
  --surface-color: #ffffff;
  --text-color: #323130;
  --text-secondary: #605e5c;
  --border-color: #e1dfdd;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --border-radius: 4px;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base layout */
html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #0b0b0b;
  color: #e5e7eb;
  height: 100dvh;
  overflow: hidden;
}

/* App Layout */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

#app:fullscreen,
#app:-webkit-full-screen {
  width: 100vw;
  height: 100dvh;
}

/* -------------------------------- */
/* Header */
/* -------------------------------- */

.app-header {
  flex: 0 0 28px;
  height: 28px;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0 6px;
  z-index: 1000;
  box-shadow: none;
  transition:
    height 180ms ease,
    padding 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.header-content {
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
}

.app-header h1 {
  display: flex;
  align-items: center;
  gap: 6x;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: #111827;
  line-height: 1;
  letter-spacing: 0;
  transition: font-size 180ms ease, gap 180ms ease;
}

.logo {
  width: 14px;
  height: 14px;
  color: #111827;
  opacity: 0.9;
  flex: 0 0 auto;
  transition: opacity 180ms ease, width 180ms ease, height 180ms ease;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  transition: gap 180ms ease;
}

/* -------------------------------- */
/* Header Buttons */
/* -------------------------------- */

.header-btn,
.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #111827;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none;
  transition:
    width 180ms ease,
    height 180ms ease,
    background-color 140ms ease,
    color 140ms ease,
    border-radius 180ms ease;
}

.icon-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  display: block;
  transition: width 180ms ease, height 180ms ease;
}

.header-btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.header-btn:active:not(:disabled),
.icon-btn:active:not(:disabled) {
  background: rgba(0, 0, 0, 0.08);
  transform: none;
}

.header-btn:disabled,
.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.close-btn:hover:not(:disabled) {
  background: #e81123;
  color: #ffffff;
}

/* -------------------------------- */
/* Fullscreen Icon Toggle */
/* -------------------------------- */

#fullscreenBtnTop .icon-enter-fullscreen,
#fullscreenBtnTop .icon-exit-fullscreen {
  display: none;
}

#fullscreenBtnTop .icon-enter-fullscreen {
  display: block;
}

#fullscreenBtnTop.is-fullscreen .icon-enter-fullscreen {
  display: none;
}

#fullscreenBtnTop.is-fullscreen .icon-exit-fullscreen {
  display: block;
}

/* -------------------------------- */
/* Connection Indicator */
/* -------------------------------- */

.connection-indicator {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: 4px;
  flex: 0 0 auto;
  transition:
    width 180ms ease,
    height 180ms ease,
    border-radius 180ms ease;
}

/* Dot */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--error-color);
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    background-color 180ms ease;
}

/* Spinner */
.status-spinner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  border-top-color: var(--primary-color);
  opacity: 0;
  position: absolute;
  pointer-events: none;
  transition: opacity 180ms ease;
  animation: statusSpin 0.8s linear infinite;
}

@keyframes statusSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Connecting */
.connection-indicator.connecting .status-dot {
  opacity: 0;
  transform: scale(0.6);
}

.connection-indicator.connecting .status-spinner {
  opacity: 1;
}

/* Connected */
.connection-indicator.connected .status-dot {
  background-color: var(--success-color);
}

/* Disconnected */
.connection-indicator.disconnected .status-dot {
  background-color: var(--error-color);
}

/* Success pulse */
.connection-indicator.connected.pulse .status-dot {
  animation: connectionPulse 420ms ease-out;
}

@keyframes connectionPulse {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }

  50% {
    transform: scale(1.4);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* -------------------------------- */
/* Fullscreen header shell mode */
/* -------------------------------- */

.app-header.is-fullscreen-active {
  height: 26px;
  padding: 0 5px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(140%) blur(6px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.app-header.is-fullscreen-active .header-actions {
  gap: 1px;
}

.app-header.is-fullscreen-active .connection-indicator,
.app-header.is-fullscreen-active .icon-btn,
.app-header.is-fullscreen-active .header-btn {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.app-header.is-fullscreen-active .icon-btn svg {
  width: 11px;
  height: 11px;
}

.app-header.is-fullscreen-active h1 {
  font-size: 11.5px;
  gap: 6px;
}

.app-header.is-fullscreen-active .logo {
  width: 13px;
  height: 13px;
  opacity: 0.82;
}

/* Main Content (fills remaining height under header) */
.main-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Connection Panel */
.connection-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.panel-content {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.panel-content h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-color);
}

.panel-content p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

/* App Grid */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.app-button {
  background-color: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 30px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  box-shadow: var(--shadow);
}

.app-button:hover:not(:disabled) {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.2);
}

.app-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #fafafa;
}

.app-button:disabled .app-icon {
  filter: grayscale(1);
}

.app-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  display: block;
}

.app-name {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-color);
}

.app-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Connection Info */
.connection-info {
  background-color: #fff4ce;
  border: 1px solid #ffb900;
  border-radius: var(--border-radius);
  padding: 15px;
  margin-top: 20px;
}

.connection-info p {
  margin: 0;
  font-size: 0.9rem;
  color: #323130;
  text-align: left;
}

/* Visibility helpers */
.guacamole-display.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.main-content.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.guacamole-display,
.main-content {
  transition: opacity 120ms ease;
}

.panel-content.hidden {
  display: none;
}

.guacamole-display,
.display-area,
#display {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
}

/* We are moving controls into the header (Cameyo-style) */
.display-controls {
  display: none;
}

/* Guacamole Display (fills main-content area) */
.guacamole-display {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: #000;
  position: relative;
}

.display-area {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* IMPORTANT: do not center the display (prevents letterboxing) */
#display {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Guacamole-specific styles */
.guac-display {
  width: 100%;
  height: 100%;
  z-index: 1;
  position: relative;
  opacity: 0;
  transition: opacity 420ms ease;
}

.guac-display.is-visible {
  opacity: 1;
}

/* Let the canvas fill the available space */
.guac-display canvas {
  display: block;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #2b579a 0%, #1f4e8c 45%, #153d73 100%);
  color: #fff;
  opacity: 1;
  transition: opacity 420ms ease;
  animation: wordBackground 8s ease-in-out infinite alternate;
}

.loading-overlay.is-fading {
  opacity: 0;
  pointer-events: none;
}

.loading-overlay.hidden {
  display: none;
}

/* BIG Word icon */
.loading-word-icon {
  width: clamp(180px, 22vw, 320px);
  height: auto;
  margin-bottom: 56px;
  filter: drop-shadow(0 20px 45px rgba(0, 0, 0, 0.35));
  animation: wordFade 0.6s ease-out;
}

/* Loading spinner */
.loading-spinner {
  width: clamp(36px, 3vw, 52px);
  height: clamp(36px, 3vw, 52px);
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: loadingSpin 0.9s linear infinite;
  margin-bottom: 26px;
}

@keyframes loadingSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes wordIntro {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes wordBackground {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.08);
  }
}

.loading-overlay p {
  font-size: clamp(1.2rem, 1.6vw, 1.6rem);
  font-weight: 500;
  letter-spacing: 0.3px;
  opacity: 0.96;
  margin: 0;
}

@keyframes wordFade {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Fullscreen styles (kept for your existing JS behavior) */
.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background-color: #000 !important;
}

.fullscreen .display-area {
  width: 100vw;
  height: 100vh;
}

/* Accessibility */
.app-button:focus,
.header-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-header {
    padding: 0 5px;
    height: 26px;
  }

  .app-header h1 {
    font-size: 11px;
    gap: 6px;
  }

  .logo {
    width: 12px;
    height: 12px;
  }

  .header-actions {
    gap: 1px;
  }

  #display,
.display-area,
.guacamole-display {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.main-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 28px); /* subtract header */
}

  .header-btn,
  .icon-btn,
  .connection-indicator {
    width: 18px;
    height: 18px;
  }

  .icon-btn svg {
    width: 10px;
    height: 10px;
  }

  .connection-panel {
    padding: 20px;
  }

  .panel-content h2 {
    font-size: 1.5rem;
  }

  .app-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .app-button {
    padding: 20px 15px;
  }

  .app-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
  }
}

/* Print styles */
@media print {
  body {
    display: none;
  }
}