/* CruxOS - Window System Styles */

.windows-container {
  position: fixed;
  inset: 0;
  bottom: 52px;
  pointer-events: none;
  z-index: var(--z-window);
}

/* ========================================
   WINDOW BASE
======================================== */
.window {
  position: absolute;
  min-width: 400px;
  min-height: 300px;
  background: linear-gradient(180deg, rgba(18, 22, 35, 0.96), rgba(14, 18, 28, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  overflow: hidden;
  animation: windowOpen var(--transition-normal) forwards;
}

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

.window.closing {
  animation: windowClose var(--transition-fast) forwards;
}

@keyframes windowClose {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.window.maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100% - 52px) !important;
  border-radius: 0;
  border: none;
}

.window.minimized {
  transform: scale(0) translateY(100px);
  opacity: 0;
  pointer-events: none;
}

.window.focused {
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(127, 140, 255, 0.2), var(--shadow-glow);
  border-color: rgba(127, 140, 255, 0.3);
}

/* ========================================
   WINDOW HEADER
======================================== */
.window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}

.window-header:active {
  cursor: grabbing;
}

.window-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.window-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.window-icon img,
.window-icon svg {
  width: 18px;
  height: 18px;
}

.window-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.window-controls {
  display: flex;
  gap: 8px;
}

.window-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--glass);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.window-btn:hover {
  background: var(--glass-strong);
  color: var(--text);
}

.window-btn.close:hover {
  background: rgba(239, 71, 111, 0.3);
  color: var(--danger);
}

.window-btn.maximize:hover {
  background: rgba(25, 178, 123, 0.3);
  color: var(--success);
}

.window-btn.minimize:hover {
  background: rgba(255, 183, 3, 0.3);
  color: var(--warning);
}

/* ========================================
   WINDOW CONTENT
======================================== */
.window-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  position: relative;
}

.window-content.no-padding {
  padding: 0;
}

/* ========================================
   WINDOW FOOTER
======================================== */
.window-footer {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========================================
   RESIZE HANDLES
======================================== */
.resize-handle {
  position: absolute;
  z-index: 10;
}

.resize-handle-n {
  top: -4px;
  left: 10px;
  right: 10px;
  height: 8px;
  cursor: n-resize;
}

.resize-handle-s {
  bottom: -4px;
  left: 10px;
  right: 10px;
  height: 8px;
  cursor: s-resize;
}

.resize-handle-e {
  top: 10px;
  right: -4px;
  bottom: 10px;
  width: 8px;
  cursor: e-resize;
}

.resize-handle-w {
  top: 10px;
  left: -4px;
  bottom: 10px;
  width: 8px;
  cursor: w-resize;
}

.resize-handle-ne {
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  cursor: ne-resize;
}

.resize-handle-nw {
  top: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  cursor: nw-resize;
}

.resize-handle-se {
  bottom: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  cursor: se-resize;
}

.resize-handle-sw {
  bottom: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  cursor: sw-resize;
}

/* ========================================
   DIALOG WINDOWS
======================================== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: overlayIn var(--transition-fast) forwards;
}

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

.dialog {
  background: linear-gradient(180deg, rgba(20, 25, 40, 0.98), rgba(15, 19, 30, 0.99));
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  min-width: 320px;
  max-width: 480px;
  animation: dialogIn var(--transition-normal) forwards;
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dialog-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.dialog-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dialog-body {
  padding: 20px 24px;
}

.dialog-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========================================
   COMMON WINDOW ELEMENTS
======================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: var(--glass-strong);
  border-color: var(--border-strong);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  border-color: transparent;
  color: white;
  box-shadow: 0 8px 24px rgba(107, 122, 255, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(107, 122, 255, 0.4);
}

.btn-success {
  background: linear-gradient(180deg, var(--success), #14966a);
  border-color: transparent;
  color: white;
}

.btn-danger {
  background: linear-gradient(180deg, var(--danger), #d63d5c);
  border-color: transparent;
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1rem;
}

/* Input fields */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.input:focus {
  background: var(--glass-strong);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

textarea.input {
  resize: vertical;
  min-height: 100px;
}

/* Labels */
.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

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

/* Cards */
.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}

.card-header {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-weight: 700;
  font-size: 1rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--glass);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tab.active {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.list-item:hover {
  background: var(--glass);
}

.list-item.selected {
  background: rgba(127, 140, 255, 0.15);
  border: 1px solid rgba(127, 140, 255, 0.2);
}

.list-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.list-item-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--glass);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.badge-primary {
  background: rgba(127, 140, 255, 0.2);
  color: var(--accent-light);
}

.badge-success {
  background: rgba(25, 178, 123, 0.2);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 71, 111, 0.2);
  color: var(--danger);
}

/* Progress */
.progress {
  height: 8px;
  background: var(--glass);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 4px;
  transition: width var(--transition-normal);
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--glass);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--text-dim);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 280px;
}

/* Dividers */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border);
  margin: 0 16px;
}
