/*
 * ╔══════════════════════════════════════════════════════════════╗
 * ║  XEYROSHEN — Your Own AI Model                              ║
 * ║  Codename: Rewire                                            ║
 * ║  © Adeshjeet_Official 2025 — All Rights Reserved            ║
 * ║  File: css/components.css — Reusable UI Components          ║
 * ╚══════════════════════════════════════════════════════════════╝
 */

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--space-2);
  padding:         10px 20px;
  border-radius:   var(--radius-md);
  font-family:     var(--font-body);
  font-size:       0.9rem;
  font-weight:     600;
  cursor:          pointer;
  border:          1px solid transparent;
  transition:      all var(--transition-base);
  white-space:     nowrap;
  user-select:     none;
  position:        relative;
  overflow:        hidden;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor:  not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background:   var(--accent);
  color:        #ffffff;
  border-color: var(--accent);
  box-shadow:   var(--shadow-accent);
}
.btn-primary:hover {
  background:   var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow:   0 6px 24px var(--accent-glow);
  transform:    translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background:   var(--surface-2);
  color:        var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background:   var(--surface-3);
  border-color: var(--border-strong);
}

/* Ghost */
.btn-ghost {
  background:   transparent;
  color:        var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background:   var(--surface-2);
  color:        var(--text-primary);
}

/* Danger */
.btn-danger {
  background:   var(--danger-dim);
  color:        var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color:      #ffffff;
}

/* Icon only */
.btn-icon {
  width:         40px;
  height:        40px;
  padding:       0;
  border-radius: var(--radius-md);
  background:    transparent;
  color:         var(--text-muted);
  border-color:  transparent;
  font-size:     1.1rem;
}
.btn-icon:hover {
  background: var(--surface-2);
  color:      var(--text-primary);
}
.btn-icon.active {
  background: var(--accent-dim);
  color:      var(--accent);
}

/* Size variants */
.btn-sm {
  padding:     6px 14px;
  font-size:   0.8rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding:     14px 28px;
  font-size:   1rem;
  border-radius: var(--radius-lg);
}

/* Ripple effect */
.btn .ripple {
  position:      absolute;
  border-radius: 50%;
  background:    rgba(255,255,255,0.3);
  transform:     scale(0);
  animation:     rippleOut 0.5s linear;
  pointer-events: none;
}
@keyframes rippleOut {
  to { transform: scale(4); opacity: 0; }
}

/* ─── Form Inputs ─────────────────────────────────────────────── */
.input, .textarea, .select {
  width:         100%;
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  color:         var(--text-primary);
  font-family:   var(--font-body);
  font-size:     0.9rem;
  transition:    all var(--transition-base);
  outline:       none;
}

.input, .select {
  height:  44px;
  padding: 0 var(--space-4);
}

.textarea {
  padding:    var(--space-3) var(--space-4);
  resize:     vertical;
  min-height: 100px;
  line-height: 1.6;
}

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

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  background:   var(--surface-1);
  box-shadow:   0 0 0 3px var(--accent-dim);
}

.input-group {
  position: relative;
}
.input-group .input {
  padding-left: 44px;
}
.input-group .input-icon {
  position:    absolute;
  left:        14px;
  top:         50%;
  transform:   translateY(-50%);
  color:       var(--text-muted);
  font-size:   1rem;
  pointer-events: none;
}

/* Form label */
.form-label {
  display:       block;
  font-size:     0.85rem;
  font-weight:   600;
  color:         var(--text-secondary);
  margin-bottom: var(--space-2);
}

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

.form-hint {
  font-size:  0.78rem;
  color:      var(--text-muted);
  margin-top: var(--space-1);
}

/* ─── Toggle Switch ───────────────────────────────────────────── */
.toggle-wrap {
  display:     flex;
  align-items: center;
  gap:         var(--space-3);
  cursor:      pointer;
  user-select: none;
}

.toggle {
  position: relative;
  width:    48px;
  height:   26px;
  flex-shrink: 0;
}

.toggle input {
  opacity:  0;
  width:    0;
  height:   0;
  position: absolute;
}

.toggle-slider {
  position:      absolute;
  inset:         0;
  background:    var(--surface-3);
  border-radius: var(--radius-pill);
  transition:    background var(--transition-base);
  border:        1px solid var(--border);
}

.toggle-slider::before {
  content:       '';
  position:      absolute;
  width:         20px;
  height:        20px;
  left:          2px;
  top:           50%;
  transform:     translateY(-50%);
  background:    var(--text-muted);
  border-radius: 50%;
  transition:    all var(--transition-bounce);
}

.toggle input:checked + .toggle-slider {
  background:    var(--accent);
  border-color:  var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform:  translateY(-50%) translateX(22px);
  background: #ffffff;
}

.toggle-label {
  font-size:   0.9rem;
  color:       var(--text-secondary);
  font-weight: 500;
}

/* ─── Top Navigation Bar ─────────────────────────────────────── */
.topnav {
  height:         var(--nav-height);
  background:     var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom:  1px solid var(--border);
  display:        flex;
  align-items:    center;
  padding:        0 var(--space-6);
  gap:            var(--space-4);
  position:       sticky;
  top:            0;
  z-index:        100;
}

.topnav-brand {
  font-family:    var(--font-display);
  font-size:      1.2rem;
  font-weight:    800;
  letter-spacing: -0.03em;
  display:        flex;
  align-items:    center;
  gap:            var(--space-2);
  text-decoration: none;
  color:          var(--text-primary);
  flex-shrink:    0;
}

.topnav-links {
  display:    flex;
  align-items: center;
  gap:         var(--space-1);
  flex:        1;
}

.topnav-link {
  padding:       8px 14px;
  border-radius: var(--radius-md);
  font-size:     0.875rem;
  font-weight:   500;
  color:         var(--text-muted);
  text-decoration: none;
  transition:    all var(--transition-fast);
}
.topnav-link:hover  { background: var(--surface-2); color: var(--text-primary); }
.topnav-link.active {
  background: var(--accent-dim);
  color:      var(--accent);
  font-weight: 600;
}

.topnav-actions {
  display:     flex;
  align-items: center;
  gap:         var(--space-2);
  margin-left: auto;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width:       var(--sidebar-width);
  height:      100vh;
  background:  var(--surface-1);
  border-right: 1px solid var(--border);
  display:     flex;
  flex-direction: column;
  overflow:    hidden;
  flex-shrink: 0;
  position:    sticky;
  top:         0;
}

.sidebar-header {
  padding:      var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
  flex-shrink:  0;
}

.sidebar-body {
  flex:      1;
  overflow-y: auto;
  padding:   var(--space-3) var(--space-2);
}

.sidebar-item {
  display:       flex;
  align-items:   center;
  gap:           var(--space-3);
  padding:       10px 12px;
  border-radius: var(--radius-md);
  cursor:        pointer;
  color:         var(--text-secondary);
  font-size:     0.875rem;
  font-weight:   500;
  transition:    all var(--transition-fast);
  text-decoration: none;
  user-select:   none;
}
.sidebar-item:hover   { background: var(--surface-2); color: var(--text-primary); }
.sidebar-item.active  {
  background:  var(--accent-dim);
  color:       var(--accent);
  font-weight: 600;
}

.sidebar-item-icon {
  font-size:   1.1rem;
  width:       22px;
  text-align:  center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding:    var(--space-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── File Chips (attached files) ────────────────────────────── */
.file-chip {
  display:       inline-flex;
  align-items:   center;
  gap:           var(--space-2);
  padding:       6px 10px;
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-md);
  font-size:     0.8rem;
  max-width:     160px;
  color:         var(--text-secondary);
  transition:    all var(--transition-fast);
}

.file-chip:hover {
  border-color: var(--border-strong);
}

.file-chip-icon {
  font-size:   1rem;
  flex-shrink: 0;
}

.file-chip-name {
  overflow:      hidden;
  white-space:   nowrap;
  text-overflow: ellipsis;
  flex:          1;
  min-width:     0;
}

.file-chip-remove {
  width:         18px;
  height:        18px;
  border-radius: 50%;
  background:    transparent;
  border:        none;
  cursor:        pointer;
  color:         var(--text-muted);
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     0.75rem;
  transition:    all var(--transition-fast);
  flex-shrink:   0;
}
.file-chip-remove:hover {
  background: var(--danger-dim);
  color:      var(--danger);
}

.file-chips-row {
  display:    flex;
  flex-wrap:  wrap;
  gap:        var(--space-2);
  padding:    var(--space-2) var(--space-4) 0;
}

/* ─── Section Header ──────────────────────────────────────────── */
.section-header {
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.section-title {
  font-family:  var(--font-display);
  font-size:    1.1rem;
  font-weight:  700;
  color:        var(--text-primary);
  display:      flex;
  align-items:  center;
  gap:          var(--space-2);
}

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background:    var(--surface-2);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       var(--space-4) var(--space-5);
}
.stat-label {
  font-size:     0.75rem;
  color:         var(--text-muted);
  font-weight:   600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.stat-value {
  font-family:   var(--font-display);
  font-size:     1.6rem;
  font-weight:   800;
  color:         var(--text-primary);
  line-height:   1;
}
.stat-sub {
  font-size:    0.75rem;
  color:        var(--text-muted);
  margin-top:   var(--space-1);
}

/* ─── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display:        flex;
  gap:            2px;
  background:     var(--surface-2);
  border-radius:  var(--radius-md);
  padding:        4px;
  border:         1px solid var(--border);
}

.tab {
  flex:          1;
  padding:       8px 16px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size:     0.875rem;
  font-weight:   500;
  cursor:        pointer;
  border:        none;
  background:    transparent;
  color:         var(--text-muted);
  transition:    all var(--transition-base);
  text-align:    center;
  white-space:   nowrap;
}

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

.tab.active {
  background: var(--surface-1);
  color:      var(--text-primary);
  font-weight: 600;
  box-shadow:  var(--shadow-sm);
}

/* ─── Theme Toggle Button ─────────────────────────────────────── */
.theme-toggle {
  width:         40px;
  height:        40px;
  border-radius: var(--radius-md);
  border:        1px solid var(--border);
  background:    var(--surface-2);
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     1.1rem;
  transition:    all var(--transition-base);
  color:         var(--text-secondary);
  flex-shrink:   0;
}
.theme-toggle:hover {
  background:   var(--surface-3);
  border-color: var(--border-strong);
  color:        var(--accent);
}

/* ─── Memory Bar (storage usage) ──────────────────────────────── */
.memory-bar-wrap {
  display:     flex;
  align-items: center;
  gap:         var(--space-3);
  font-size:   0.78rem;
  color:       var(--text-muted);
}
.memory-bar {
  flex:          1;
  height:        4px;
  background:    var(--surface-3);
  border-radius: var(--radius-pill);
  overflow:      hidden;
}
.memory-bar-fill {
  height:        100%;
  border-radius: var(--radius-pill);
  background:    var(--accent);
  transition:    width 0.6s ease;
}
.memory-bar-fill.warn   { background: var(--warning); }
.memory-bar-fill.danger { background: var(--danger);  }

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding:    var(--space-12);
  color:      var(--text-muted);
}
.empty-state-icon {
  font-size:     2.5rem;
  margin-bottom: var(--space-3);
  opacity:       0.5;
}
.empty-state-title {
  font-size:    1rem;
  font-weight:  600;
  color:        var(--text-secondary);
  margin-bottom: var(--space-2);
}
.empty-state-desc {
  font-size: 0.875rem;
  max-width: 300px;
  margin:    0 auto;
}

/* ─── Responsive Sidebar Collapse ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left:     -100%;
    z-index:  200;
    width:    80vw;
    max-width: 300px;
    transition: left var(--transition-base);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    left: 0;
  }
  .topnav {
    padding: 0 var(--space-4);
  }
}
