/**
 * Drawer System - Shared infrastructure for slide-in panels
 * 
 * Used by: SignInModal, CreateGalleryModal, ProfileModal, GetInTouchModal
 * Pattern: Slides from right, matches navigation sidebar behavior
 * Mobile: Full-width on small screens (<640px)
 */

/* CSS Custom Properties - Centralized control for all drawer panels */
:root {
  /* Drawer Panel System */
  --drawer-width: 320px;
  --drawer-top-offset: var(--topbar-height);
  --drawer-right-margin: 0px;
  --drawer-bottom-margin: 0px;
  --drawer-border-radius: 0px;
  --drawer-z-index: 300;
  /* Protected drawers (e.g. Create Gallery) sit below the sidebar so the sidebar
     can open on top without a z-fight. Only closed via Cancel/Submit — never by
     outside-click — so being visually beneath the sidebar is intentional. */
  --protected-drawer-z-index: 200;
  /* Sidebar sits above regular drawers so it always comes to front when opened. */
  --sidebar-z-index: 350;
  --drawer-transition-duration: 0.3s;
  --drawer-transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base drawer - hidden by default */
.drawer {
  display: none;
  position: fixed;
  top: var(--drawer-top-offset);
  right: var(--drawer-right-margin);
  bottom: var(--drawer-bottom-margin);
  background: var(--color-surface-primary);
  border-left: var(--border-fine);
  border-radius: var(--drawer-border-radius);
  box-shadow: var(--shadow-float);
  z-index: var(--drawer-z-index);
  transform: translateX(100%);
  transition: transform var(--drawer-transition-duration) var(--drawer-transition-timing);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Visible state - slides in from right */
.drawer--visible {
  display: block;
  transform: translateX(0);
}

/* Width variants - all use unified width now */
.drawer--narrow {
  width: var(--drawer-width);
}

.drawer--medium {
  width: var(--drawer-width);
}

.drawer--wide {
  width: var(--drawer-width);
}

/* Mobile: sync top offset with the smaller topbar */
@media (max-width: 768px) {
  :root {
    --drawer-top-offset: var(--topbar-height-mobile);
  }
}

/* Mobile responsive - full width on small screens */
@media (max-width: 640px) {
  .drawer {
    width: 100% !important;
    border-left: none;
    box-shadow: none;
  }
}

/* Drawer content container */
.drawer__content {
  padding: 10px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Drawer header */
.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-surface-tertiary);
}

.drawer__title {
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0;
}

.drawer__subtitle {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin: 8px 0 0 0;
  font-family: var(--font-body);
}

/* Close button */
.drawer__close {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.drawer__close:hover {
  color: var(--color-text-primary);
}

/* Drawer body - scrollable content area */
.drawer__body {
  flex: 0 1 auto;
  overflow-y: auto;
}

/* Drawer footer - action buttons */
.drawer__footer {
  flex: 0 0 auto;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--color-surface-tertiary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.drawer__footer .button {
  flex: 1 1 auto;
}

/* Full-width divider before destructive action — hidden by default */
.drawer__footer-divider {
  display: none;
  width: 100%;
  border: none;
  border-top: 1px solid var(--color-surface-tertiary);
  margin: 0;
  flex: 0 0 100%;
}

/* Show divider when remove button is visible */
.drawer__footer:has(#removeImageBtn:not(.hidden)) .drawer__footer-divider {
  display: block;
}

.drawer__footer #removeImageBtn:not(.hidden) {
  flex: 1 1 100%;
}

/* Protected drawer override — Create Gallery sits below sidebar z-index */
#createGalleryModal {
  z-index: var(--protected-drawer-z-index);
}

/* Drawer form input */
.drawer__input {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-surface-secondary);
  border: var(--border-fine);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.drawer__input:focus {
  outline: none;
  border-color: var(--color-accent-brass-light);
}

.drawer__input::placeholder {
  color: var(--color-text-secondary);
}

/* Drawer inline message (success/error feedback) */
.drawer__message {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: var(--color-text-primary);
  border: 1px solid var(--color-surface-tertiary);
  background: var(--color-surface-secondary);
}

/* Confirmation Modal Specific Styles */
.confirmation-modal__message {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
  /* Allow line breaks in message */
}

.confirmation-modal__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.confirmation-modal__actions button {
  flex: 0 1 auto;
  min-width: 100px;
}
