// =============================================================================
// Windows UI Kit Design System - Fluent Design
// Based on Windows 11 Fluent Design principles
// =============================================================================

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

:root {
  // Windows UI Kit - Light Mode Color System
  // Background layers ( Mica-inspired depth )
  --bg-primary: #f3f3f38e;
  --bg-secondary: #ffffff70;
  --bg-tertiary: #ebebeb;
  --bg-elevated: #ffffffe3;
  --bg-mica: rgba(243, 243, 243, 0.473);

  // Text colors ( semantic naming )
  --text-primary: #1a1a1a;
  --text-secondary: #5d5d5d;
  --text-tertiary: #8a8a8a;
  --text-disabled: #b8b8b8;

  // Accent colors ( Windows blue )
  --accent: #0078d4;
  --accent-hover: #106ebe;
  --accent-pressed: #005a9e;
  --accent-light: rgba(0, 120, 212, 0.1);
  --accent-text: #0078d4;

  // Border colors
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --border-strong: #c8c8c8;
  --border-focus: var(--accent);

  // Status colors
  --success: #107c10;
  --success-bg: rgba(16, 124, 16, 0.1);
  --danger: #c42b1c;
  --danger-bg: rgba(196, 43, 28, 0.1);
  --warning: #9d5d00;
  --warning-bg: rgba(157, 93, 0, 0.1);
  --info: #0078d4;
  --info-bg: rgba(0, 120, 212, 0.1);

  // Control colors ( Windows 11 style )
  --control-fill: #f9f9f98e;
  --control-fill-hover: #eaeaea;
  --control-fill-pressed: #e0e0e0;
  --control-fill-disabled: #f5f5f5;

  // Shadow system ( layer-based depth )
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 8px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.16), 0 8px 16px rgba(0, 0, 0, 0.08);

  // Radius system ( Windows 11 uses 4-8px )
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  // Spacing system
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;

  // Typography
  --font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;

  // Animation
  --transition-fast: 0.1s ease;
  --transition: 0.15s ease;
  --transition-smooth: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

// =============================================================================
// Dark Mode ( Windows 11 Dark Theme )
// =============================================================================

.dark {
  --bg-primary: #1f1f1f;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #383838;
  --bg-elevated: #333333;
  --bg-mica: rgba(31, 31, 31, 0.85);

  --text-primary: #ffffff;
  --text-secondary: #b8b8b8;
  --text-tertiary: #787878;
  --text-disabled: #555555;

  --accent: #60cdff;
  --accent-hover: #82d1ff;
  --accent-pressed: #4ab3ff;
  --accent-light: rgba(96, 205, 255, 0.15);
  --accent-text: #60cdff;

  --border: #404040;
  --border-light: #333333;
  --border-strong: #555555;

  --success: #6ccb5f;
  --success-bg: rgba(108, 203, 95, 0.15);
  --danger: #ff6b6b;
  --danger-bg: rgba(255, 107, 107, 0.15);
  --warning: #fce100;
  --warning-bg: rgba(252, 225, 0, 0.15);
  --info: #60cdff;
  --info-bg: rgba(96, 205, 255, 0.15);

  --control-fill: #333333;
  --control-fill-hover: #3d3d3d;
  --control-fill-pressed: #474747;
  --control-fill-disabled: #2d2d2d;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
}

// =============================================================================
// Animations
// =============================================================================

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

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

// =============================================================================
// Base Styles
// =============================================================================

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

// =============================================================================
// Scrollbar ( Windows 11 Style )
// =============================================================================

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
  background-clip: content-box;
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

// =============================================================================
// App Layout
// =============================================================================

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.content {
  flex: 1;
  padding: var(--space-3xl) var(--space-2xl);
  overflow-y: auto;
  background: var(--bg-primary);
}

.content section {
  animation: fadeInUp 0.25s ease;
}

// =============================================================================
// Content Header
// =============================================================================

.content-header {
  margin-bottom: var(--space-xl);
}

.content-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
  animation: fadeInDown 0.2s ease;
}

.content-desc {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  line-height: 1.5;
  animation: fadeIn 0.3s ease 0.05s backwards;
}

// =============================================================================
// Card Component
// =============================================================================

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  transition:
    box-shadow var(--transition-smooth),
    border-color var(--transition-smooth);
  animation: fadeInUp 0.3s ease backwards;

  &:last-child {
    margin-bottom: 0;
  }

  &:hover {
    box-shadow: var(--shadow-sm);
  }
}

.card:nth-child(1) {
  animation-delay: 0.02s;
}
.card:nth-child(2) {
  animation-delay: 0.05s;
}
.card:nth-child(3) {
  animation-delay: 0.08s;
}

.card-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  letter-spacing: -0.01em;

  .iconpark-icon {
    color: var(--accent);
  }
}

// =============================================================================
// Form Controls
// =============================================================================

.form-group {
  margin-bottom: var(--space-lg);

  &:last-child {
    margin-bottom: 0;
  }
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.01em;
}

.form-required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background: var(--control-fill);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  letter-spacing: -0.01em;

  &::placeholder {
    color: var(--text-tertiary);
  }

  &:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--control-fill-hover);
  }

  &:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
  }

  &:disabled {
    background: var(--control-fill-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
  }
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 400;
  background: var(--control-fill);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235d5d5d' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: 36px;
  transition: all var(--transition);
  letter-spacing: -0.01em;

  &:hover:not(:disabled) {
    border-color: var(--border-strong);
    background-color: var(--control-fill-hover);
  }

  &:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
  }

  &:disabled {
    background-color: var(--control-fill-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
  }
}

.form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background: var(--control-fill);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  transition: all var(--transition);

  &:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
  }
}

// =============================================================================
// Icon
// =============================================================================

.iconpark-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.125em;
  flex-shrink: 0;

  svg {
    display: block;
  }
}

// =============================================================================
// Button ( Windows 11 Style )
// =============================================================================

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  transition: all var(--transition);
  letter-spacing: -0.01em;
  position: relative;
  overflow: hidden;

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
  }
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;

  &:hover:not(:disabled) {
    background: var(--accent-hover);
  }

  &:active:not(:disabled) {
    background: var(--accent-pressed);
    transform: scale(0.98);
  }
}

.btn-secondary {
  background: var(--control-fill);
  color: var(--text-primary);
  border: 1px solid var(--border);

  &:hover:not(:disabled) {
    background: var(--control-fill-hover);
    border-color: var(--border-strong);
  }

  &:active:not(:disabled) {
    background: var(--control-fill-pressed);
    transform: scale(0.98);
  }
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;

  &:hover:not(:disabled) {
    background: #d32f2f;
  }

  &:active:not(:disabled) {
    background: #b71c1c;
    transform: scale(0.98);
  }
}

.btn-sm {
  padding: 4px 10px;
  font-size: var(--font-size-xs);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);

  &:hover:not(:disabled) {
    background: var(--control-fill-hover);
  }

  &:active:not(:disabled) {
    background: var(--control-fill-pressed);
  }
}

// =============================================================================
// Side Panel
// =============================================================================

.side-panel-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);

  &:hover {
    background: var(--control-fill-hover);
    color: var(--text-primary);
  }

  svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
  }
}

// =============================================================================
// Empty State
// =============================================================================

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  background: var(--control-fill);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
  color: var(--text-tertiary);
}

.empty-state-title {
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.empty-state-desc {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

// =============================================================================
// Dialog
// =============================================================================

.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
  animation: fadeIn 0.15s ease;
}

.dialog-overlay-top {
  z-index: 1400;
}

.dialog {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  min-width: 360px;
  max-width: 480px;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.2s ease;
}

.dialog-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

.dialog-confirm-text {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: 1.5;
}

.dialog-body {
  padding: var(--space-md) 0;
  max-height: 60vh;
  overflow-y: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

// Message Dialog
.message-dialog {
  position: relative;
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
}

.message-dialog-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-md);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;

  svg {
    width: 24px;
    height: 24px;
  }
}

.message-dialog-icon-info {
  background: var(--info-bg);
  color: var(--info);
}

.message-dialog-icon-success {
  background: var(--success-bg);
  color: var(--success);
}

.message-dialog-icon-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.message-dialog-icon-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.message-dialog-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.message-dialog-message {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.message-dialog .dialog-actions {
  justify-content: center;
  margin-top: var(--space-xl);

  .btn {
    min-width: 100px;
  }
}

// =============================================================================
// List Items ( Server List, Profile List )
// =============================================================================

.server-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
}

.server-item {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-smooth);
  animation: fadeIn 0.25s ease backwards;

  &:nth-child(1) {
    animation-delay: 0.02s;
  }
  &:nth-child(2) {
    animation-delay: 0.04s;
  }
  &:nth-child(3) {
    animation-delay: 0.06s;
  }
  &:nth-child(4) {
    animation-delay: 0.08s;
  }
  &:nth-child(5) {
    animation-delay: 0.1s;
  }

  &:last-child {
    border-bottom: none;
  }

  &:hover {
    background: var(--control-fill);
  }

  &.selected {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding-left: calc(var(--space-lg) - 3px);
  }
}

.server-info {
  flex: 1;
  min-width: 0;
}

.server-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.server-desc {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
