/*
 * styles.css
 *
 * Main stylesheet for the Button Maker application.
 * Unified with the San Rafael Public Library internal tool visual identity.
 */

/* VARIABLES & RESET */
:root {
  --primary-color: #5c6bc0;
  --primary-hover: #3f51b5;
  --primary-light: #e8eaf6;
  --secondary-color: #37474f;
  --secondary-light: #546e7a;
  --success-color: #43a047;
  --success-hover: #388e3c;
  --danger-color: #e53935;
  --warning-color: #fb8c00;
  --bg-color: #f5f7fa;
  --sidebar-bg: #ffffff;
  --border-color: #e1e5eb;
  --border-light: #f0f2f5;
  --text-color: #2d3748;
  --text-light: #718096;
  --text-muted: #a0aec0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */

#main-content {
  display: flex;
  height: calc(100vh - 52px);
}

.sidebar {
  width: 340px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 2px 0 12px rgba(0,0,0,0.06);
  position: relative;
  transition: width var(--transition-normal), margin var(--transition-normal), padding var(--transition-normal);
  z-index: 5;
  overflow-y: auto;
  padding: 16px;
}

.sidebar.collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  margin-left: -1px;
  overflow: hidden;
  border-right: none;
  box-shadow: none;
}

#canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#canvas-area-scroll {
  width: 100%;
  height: 100%;
  display: flex;
  background: var(--bg-color);
  overflow: auto;
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 10;
  padding: 4px;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-color);
  font-size: 0.85rem;
  transition: background var(--transition-fast);
}

.zoom-btn:hover {
  background: var(--border-light);
}

.zoom-label {
  min-width: 54px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  font-family: inherit;
}

.zoom-label:hover {
  background: var(--border-light);
  color: var(--text-color);
}

/* Header */

.app-header {
  background: var(--secondary-color);
  color: white;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 20;
  gap: 16px;
}

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

.app-header .logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  border-right: 1px solid rgba(255,255,255,0.2);
}

.app-header .logo i {
  font-size: 1.2rem;
  opacity: 0.9;
}

.header-credit {
  font-family: 'EB Garamond', serif;
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.6;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 6px;
}

/* Panel Toggle Buttons in Header */
.header-panel-toggles {
  display: flex;
  gap: 4px;
}

.panel-toggle-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.panel-toggle-btn:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

.panel-toggle-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* Info Labels & Mode Toggles (Now in Sidebar) */

.button-size-label {
  font-size: 15px;
  color: var(--secondary-light);
  background: var(--border-light);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-weight: 600;
}

.mode-toggle {
  display: flex;
  background: var(--border-light);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border-color);
}

.mode-btn {
  padding: 5px 12px;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.mode-btn:hover:not(.active) {
  color: var(--text-color);
}

/* Standard Buttons */

.btn {
  padding: 10px 16px;
  border: none;
  background: white;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-color);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--border-light);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  border: none;
  box-shadow: 0 2px 4px rgba(92, 107, 192, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(92, 107, 192, 0.35);
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
  text-align: center;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
  border: none;
}

.btn-danger:hover {
  background: #c62828;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-icon.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Header Action Buttons (after .btn so they win in cascade) */
.btn-header {
  background-color: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  min-width: 75px;
  justify-content: center;
}

.btn-header:hover {
  background-color: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

.btn-header-primary {
  background-color: var(--success-color);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  min-width: 120px;
  justify-content: center;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(67, 160, 71, 0.3);
}

.btn-header-primary:hover {
  background-color: var(--success-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(67, 160, 71, 0.4);
}

/* Sidebar Specific Scaling */
.sidebar .btn-small {
  font-size: 0.8rem;
}

.sidebar .input {
  font-size: 0.85rem;
}

/* Sidebar Sections */

.sidebar-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sidebar-heading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-light);
  margin-bottom: 8px;
}

/* Inputs */

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  background-color: #fff;
  color: var(--text-color);
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.color-input {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  transition: border-color var(--transition-fast);
}

.color-input:hover {
  border-color: var(--primary-color);
}

/* Color Swatches */

.color-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: var(--text-muted);
}

.color-swatch.active {
  border-color: var(--text-color);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

/* Control Rows */

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.control-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-color);
  margin: 0;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label, .radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
  cursor: pointer;
}

input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* Canvas Wrapper */

.canvas-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: auto;
}

.canvas-wrapper canvas {
  border-radius: 50%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  transition: box-shadow var(--transition-normal);
}

.canvas-wrapper canvas:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.1);
}

/* Tool Controls */

.image-controls {
  margin-top: 12px;
  padding: 12px;
  background: var(--border-light);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

/* Sheet View */

.sheet-view {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
}

.sheet-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
}

.sheet-selection-hint {
  margin-left: auto;
  font-size: 13.5px;
  font-weight: bold;
  color: #888;
  white-space: nowrap;
}

.sheet-name-row label {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
}

.list-name-input {
  width: 250px;
  padding: 6px 10px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: white;
  color: var(--text-color);
  transition: all var(--transition-fast);
}

.list-name-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.list-name-input::placeholder {
  color: var(--text-muted);
}

.sheet-outer-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.sheet-page {
  position: relative;
  background: white;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
}

.sheet-col-headers {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.sheet-main-area {
  display: flex;
  align-items: flex-start;
}

.sheet-row-headers {
  display: flex;
  flex-direction: column;
  margin-right: 8px;
}

.sheet-grid {
  display: inline-grid;
}

.sheet-cell {
  position: relative;
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 50%;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-cell:hover {
  border-color: var(--text-muted);
  transform: scale(1.02);
}

.sheet-cell.selected {
  border-color: var(--secondary-color); /* Rich black outline */
  box-shadow: 0 0 0 2px var(--secondary-color), 0 8px 16px rgba(0,0,0,0.25); /* Double thick ring + heavy drop shadow */
  transform: scale(1.08); /* Bumping the zoom slightly to make it pop */
  z-index: 2;
}

.sheet-cell canvas {
  display: block;
  border-radius: 50%;
}

.override-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: var(--primary-color);
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  min-width: 32px;
}

.sheet-header:hover {
  background: var(--border-light);
  color: var(--text-color);
}

.sheet-header.selected {
  background: var(--primary-color);
  color: white;
}

.sheet-controls-bar {
  margin-top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  background: transparent;
  padding: 4px 0 4px 36px;
  border-radius: var(--radius);
  align-self: stretch;
  margin-bottom: 8px;
  min-height: 37px; /* Reserve space for button height to prevent layout shift */
  box-sizing: border-box;
}

/* Upload Label */

.upload-label {
  display: block;
  cursor: pointer;
  background: white;
  border: 1px dashed var(--text-muted);
  color: var(--text-light);
  padding: 12px;
  text-align: center;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.upload-label:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

/* Notification */

#notification-area {
  position: fixed; top: 0; left: 0; width: 100%; padding: 0 16px;
  text-align: center; color: white; background: var(--danger-color);
  transform: translateY(-100%); transition: transform 0.3s, visibility 0.3s; z-index: 1000;
  visibility: hidden;
  height: 52px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
#notification-area.show { transform: translateY(0); visibility: visible; }
#notification-area.success { background: var(--success-color); }
#notification-area.info { background: var(--primary-color); }

/* Utilities */

.hidden {
  display: none !important;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Sheet Mode: Reset & Override Panel */

.reset-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
  background: white;
  border: 1px solid var(--danger-color);
  color: var(--danger-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.reset-btn:hover {
  background: var(--danger-color);
  color: white;
}

/* Main Design Banner */

#main-design-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: #e8f0fe;
  border: 1px solid #c2d4f8;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: #1a3a6e;
  box-shadow: var(--shadow-sm);
}

#main-design-banner strong {
  font-weight: 700;
}

/* Slot Edit Banner */

#slot-edit-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: #fff3cd;
  border: 1px solid #ffe69c;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: #664d03;
  box-shadow: var(--shadow-sm);
}

#slot-edit-banner strong {
  font-weight: 700;
}

/* Gradient Presets */

.gradient-presets {
  flex: 1; /* Forces the grid to fill the remaining space in the row */
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
}

.gradient-preset-btn {
  aspect-ratio: 2/1;
  width: 100%;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  display: block; /* Ensures aspect-ratio calculates correctly on empty buttons */
}

.gradient-preset-btn:hover {
  transform: translateY(-2px);
  border-color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.gradient-preset-btn.active {
  border-color: var(--text-color);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

/* Quick Reference Link & Modal */

.quick-ref-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.quick-ref-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.quick-ref-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-ref-overlay.hidden {
  display: none;
}

.quick-ref-modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px 24px;
  min-width: 260px;
  max-width: 340px;
  animation: quickRefFadeIn 0.15s ease;
}

@keyframes quickRefFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.quick-ref-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0 0 14px 0;
  text-align: center;
}

.quick-ref-footer {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.quick-ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.quick-ref-table th {
  text-align: center;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-light);
  padding: 6px 12px;
  border-bottom: 2px solid var(--border-color);
}

.quick-ref-table td {
  text-align: center;
  padding: 7px 12px;
  color: var(--text-color);
  border-bottom: 1px solid var(--border-light);
}

.quick-ref-table tr:last-child td {
  border-bottom: none;
}

.quick-ref-table tbody tr:hover {
  background: var(--border-light);
}

/* Range slider */

input[type="range"] {
  width: 100%;
  margin: 8px 0;
  accent-color: var(--primary-color);
}
