/* ==========================================================================
   sidebar.css - Collapsible Accounts & Real-time Quota Sidebar
   Dooze Clip Generator / Gemini-inspired Soft-Black Interface
   ========================================================================== */

:root {
  --sidebar-w-expanded: 240px;
  --sidebar-w-collapsed: 64px;
  --sidebar-w: var(--sidebar-w-expanded);
}

body.sidebar-is-collapsed {
  --sidebar-w: var(--sidebar-w-collapsed);
}

/* Page offset on desktop to prevent overlap */
@media (min-width: 900px) {
  body {
    padding-left: calc(var(--sidebar-w) + 1.5rem) !important;
    transition: padding-left 220ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .bottom-bar {
    left: var(--sidebar-w) !important;
    width: calc(100% - var(--sidebar-w)) !important;
    transition: left 220ms cubic-bezier(0.16, 1, 0.3, 1), width 220ms cubic-bezier(0.16, 1, 0.3, 1);
  }
}

/* ==========================================================================
   App Sidebar Container
   ========================================================================== */

.app-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  background-color: var(--surface, #1e1f20);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 110;
  transition: width 220ms cubic-bezier(0.16, 1, 0.3, 1), transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  user-select: none;
  overflow: hidden;
}

/* Mobile drawer behavior */
@media (max-width: 899px) {
  .app-sidebar {
    width: var(--sidebar-w-expanded);
    transform: translateX(-100%);
  }
  .app-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.7);
  }
}

.sidebar-backdrop {
  display: none;
}
@media (max-width: 899px) {
  .sidebar-backdrop.active {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 105;
  }
}

/* ==========================================================================
   Sidebar Header
   ========================================================================== */

.sidebar-header {
  height: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 9px;
  background: var(--gemini-gradient, linear-gradient(135deg, #4285F4 0%, #9B72CB 50%, #D96570 100%));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(66, 133, 244, 0.3);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  transition: opacity 180ms ease;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 0 !important;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--duration-fast, 150ms) var(--ease-gemini), color 150ms ease, transform var(--duration-fast, 150ms) var(--ease-gemini);
}

.sidebar-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.sidebar-icon-btn:active {
  transform: scale(0.94);
}

.sidebar-icon-btn.spinning svg {
  animation: spin 700ms linear infinite;
}

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

/* ==========================================================================
   Collapsed View Adjustments
   ========================================================================== */

body.sidebar-is-collapsed .sidebar-brand-text,
body.sidebar-is-collapsed .sidebar-stats,
body.sidebar-is-collapsed .sidebar-acc-details,
body.sidebar-is-collapsed .sidebar-footer-text {
  display: none !important;
}

body.sidebar-is-collapsed .sidebar-header {
  justify-content: center;
  padding: 0 8px;
}

body.sidebar-is-collapsed .sidebar-brand {
  display: none;
}

body.sidebar-is-collapsed .sidebar-header-actions {
  width: 100%;
  justify-content: center;
}

body.sidebar-is-collapsed .sidebar-acc-item {
  padding: 8px 0;
  justify-content: center;
}

body.sidebar-is-collapsed .sidebar-acc-avatar-wrap {
  margin: 0 auto;
}

body.sidebar-is-collapsed .sidebar-footer {
  padding: 10px 8px;
}

body.sidebar-is-collapsed .sidebar-btn-add {
  justify-content: center;
  padding: 8px;
}

/* ==========================================================================
   Sidebar Stats Bar
   ========================================================================== */

.sidebar-stats {
  padding: 10px 14px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sidebar-stats-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-live-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(52, 168, 83, 0.15);
  color: #81c995;
  font-weight: 500;
}

/* ==========================================================================
   Account List
   ========================================================================== */

.sidebar-acc-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-acc-list::-webkit-scrollbar {
  width: 5px;
}
.sidebar-acc-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Account Item Card */
.sidebar-acc-item {
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  text-decoration: none;
}

.sidebar-acc-item:hover {
  background-color: rgba(255, 255, 255, 0.065);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.sidebar-acc-item.is-active {
  background-color: rgba(168, 199, 250, 0.09);
  border-color: rgba(168, 199, 250, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

/* Avatar with Status Dot */
.sidebar-acc-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  min-width: 36px;
}

.sidebar-acc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 160ms ease;
}

.sidebar-acc-item.is-active .sidebar-acc-avatar {
  background: rgba(168, 199, 250, 0.18);
  color: var(--accent);
  border-color: rgba(168, 199, 250, 0.5);
}

.sidebar-acc-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #141518;
}

.sidebar-acc-dot.online {
  background-color: #34a853;
  box-shadow: 0 0 6px rgba(52, 168, 83, 0.7);
}

.sidebar-acc-dot.offline {
  background-color: #5f6368;
}

/* Account Details Area */
.sidebar-acc-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sidebar-acc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sidebar-acc-name-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.sidebar-acc-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-acc-port {
  font-size: 10.5px;
  color: var(--text-tertiary);
  font-family: monospace;
}

.sidebar-acc-badge-active {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(168, 199, 250, 0.2);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sidebar-acc-badge-pro {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(197, 138, 249, 0.18);
  color: #d7aefb;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Real Live Quota Mini Bar */
.sidebar-quota-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-quota-bar-track {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.sidebar-quota-bar-fill {
  height: 100%;
  border-radius: 999px;
  background-color: var(--accent);
  transition: width 300ms ease-out;
}

.sidebar-quota-bar-fill.normal {
  background-color: #8ab4f8;
}

.sidebar-quota-bar-fill.warning {
  background-color: #f2c66d;
}

.sidebar-quota-bar-fill.critical {
  background-color: #f28b82;
}

.sidebar-quota-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-secondary);
}

.sidebar-quota-val {
  font-weight: 500;
  color: var(--text-primary);
}

.sidebar-quota-reset {
  color: var(--text-tertiary);
  font-size: 9.5px;
}

.sidebar-quota-fresh {
  font-size: 10.5px;
  color: #81c995;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   Sidebar Footer
   ========================================================================== */

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background-color: rgba(0, 0, 0, 0.18);
  margin-top: auto;
}

.sidebar-active-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-pill, 999px);
  background: rgba(255, 255, 255, 0.05);
  border: 0 !important;
  cursor: pointer;
  transition: all 140ms ease;
  user-select: none;
  width: 100%;
}

.sidebar-active-user:hover {
  background: rgba(255, 255, 255, 0.09);
}

.active-user-avatar {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  background: #2a2b30;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0 !important;
  letter-spacing: -0.02em;
}

.active-user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
}

.active-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-user-status {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.active-user-status .active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #81c995;
  box-shadow: 0 0 6px rgba(129, 201, 149, 0.5);
}

.sidebar-user-action {
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 140ms ease, background 140ms ease;
}

.sidebar-user-action:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

/* Collapsed view adjustments */
body.sidebar-is-collapsed .active-user-info,
body.sidebar-is-collapsed .sidebar-user-action {
  display: none !important;
}

body.sidebar-is-collapsed .sidebar-active-user {
  justify-content: center;
  padding: 6px 0;
  border: none;
  background: transparent;
}

/* Mobile Toggle Button on Top-Header */
.mobile-sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
}
@media (max-width: 899px) {
  .mobile-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .top-header {
    justify-content: space-between !important;
  }
}
