/* Custom CSS for Valenwood Apparel Spec Sheet Studio */

/* Theme Variables */
:root {
  --bg-app: #050811;
  --bg-panel: rgba(14, 22, 38, 0.75);
  --bg-panel-solid: #0e1626;
  --bg-panel-border: rgba(30, 41, 59, 0.5);
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: rgba(16, 185, 129, 0.12);
  --text-main: #f8fafc;
  --text-muted: #64748b;
  --input-bg: #080e1a;
  --input-border: #1e293b;
  --input-focus: #10b981;
  --yellow-header: #fbbf24;
  --yellow-header-text: #000000;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5), 0 4px 12px -2px rgba(0, 0, 0, 0.3);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
}

body.light-theme {
  --bg-app: #f4f5f7;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --bg-panel-solid: #ffffff;
  --bg-panel-border: rgba(226, 232, 240, 0.8);
  --accent: #059669;
  --accent-hover: #047857;
  --accent-light: rgba(5, 150, 105, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-focus: #059669;
}

/* Reset and Core Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background-color: var(--bg-panel-solid);
  border-bottom: 1px solid var(--bg-panel-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #ffffff;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.logo-icon i {
  width: 1.25rem;
  height: 1.25rem;
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  background: linear-gradient(to right, var(--text-main), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--input-bg);
  border-color: var(--bg-panel-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--input-border);
  border-color: var(--text-muted);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--bg-panel-border);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--accent-light);
  border-color: var(--accent);
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background-color: var(--input-bg);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  aspect-ratio: 1;
}

.btn-icon:hover {
  background-color: var(--input-border);
  color: var(--accent);
}

.btn-icon-only {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-circle {
  border-radius: 9999px;
  padding: 0.35rem;
  width: 1.75rem;
  height: 1.75rem;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  width: 100%;
  max-width: 100vw;
}

/* Sidebar styling */
.sidebar {
  background-color: var(--bg-panel-solid);
  border-right: 1px solid var(--bg-panel-border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--bg-panel-border);
}

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

.sidebar-section h3 {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-section h3 i {
  width: 1rem;
  height: 1rem;
  color: var(--accent);
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.col-6 {
  flex: 0 0 calc(50% - 0.375rem);
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  font-size: 0.875rem;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23a1a1aa' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.25rem;
  padding-right: 2rem;
}

/* Checkbox Style */
.checkbox-group {
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-label span {
  font-size: 0.75rem;
  color: var(--text-main);
}

.template-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Sizing Tag Manager */
.size-manager {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.size-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.25rem;
  border: 1px dashed var(--bg-panel-border);
  border-radius: var(--radius-md);
  background-color: rgba(0, 0, 0, 0.1);
}

.size-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background-color: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.size-badge button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 0;
}

.size-badge button:hover {
  color: #ef4444;
}

.add-size-row {
  display: flex;
  gap: 0.5rem;
}

.add-size-row input {
  flex: 1;
}

/* Image Upload Dropzone */
.image-upload-container {
  width: 100%;
}

.image-dropzone {
  position: relative;
  width: 100%;
  aspect-ratio: 4/5;
  border: 2px dashed var(--bg-panel-border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.15);
  transition: all var(--transition-normal);
}

.image-dropzone:hover,
.image-dropzone.dragover {
  border-color: var(--accent);
  background-color: var(--accent-light);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  pointer-events: none;
}

.upload-icon {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.image-dropzone:hover .upload-icon {
  color: var(--accent);
}

.dropzone-prompt p {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
}

.file-size-limit {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.image-preview-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background-color: var(--bg-panel-solid);
}

.image-preview-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-preview-wrapper .btn-danger {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 20;
}

.hidden {
  display: none !important;
}

/* Editor Panel (Main Content) */
.editor-panel {
  padding: 2rem;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.glass-panel {
  background-color: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.editor-card {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  min-height: 100%;
}

/* Editable Title Banner */
.table-title-banner {
  background-color: var(--yellow-header);
  color: var(--yellow-header-text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  text-transform: uppercase;
  border: 1px solid var(--input-border);
  border-bottom: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.table-title-banner:hover {
  opacity: 0.9;
}

/* Spec Table styling */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--bg-panel-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.spec-table th,
.spec-table td {
  padding: 0.65rem 0.5rem;
  border-right: 1px solid var(--bg-panel-border);
  border-bottom: 1px solid var(--bg-panel-border);
  vertical-align: middle;
}

.spec-table th:last-child,
.spec-table td:last-child {
  border-right: none;
}

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

/* Headers */
.spec-table thead tr {
  background-color: var(--yellow-header);
}

.spec-table th {
  color: var(--yellow-header-text);
  font-weight: 800;
  font-size: 0.8rem;
  text-align: center;
  letter-spacing: 0.05em;
  padding: 0.75rem 0.5rem;
}

.spec-table th.col-label {
  text-align: left;
  min-width: 250px;
}

.spec-table th.col-actions {
  width: 50px;
  min-width: 50px;
  background-color: rgba(0, 0, 0, 0.05);
}

/* Columns Actions */
.cell-actions-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.cell-actions-container button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem;
}

.cell-actions-container button:hover {
  color: var(--accent);
}

.cell-actions-container button.btn-row-del:hover {
  color: #ef4444;
}

/* Edit Inputs Inside Cells */
.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  font-family: inherit;
  font-weight: inherit;
  font-size: 0.875rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.spec-table tbody td:not(.col-actions):not(.col-label) .cell-input {
  text-align: center;
}

.cell-input:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--bg-panel-border);
}

.cell-input:focus {
  background-color: var(--input-bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
  color: var(--text-main) !important;
}

/* Table body tr styling */
.spec-table tbody tr {
  transition: background-color var(--transition-fast);
}

.spec-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Row Style Overrides */
.spec-table tr.style-bold {
  font-weight: 700;
}

.spec-table tr.style-italic {
  font-style: italic;
}

/* Colors */
.spec-table tr.color-red {
  color: #ef4444 !important;
}

.spec-table tr.color-green {
  color: #10b981 !important;
}

.spec-table tr.color-blue {
  color: #3b82f6 !important;
}

/* Fills */
.spec-table tr.fill-yellow {
  background-color: rgba(251, 191, 36, 0.08) !important;
}

.spec-table tr.fill-yellow:hover {
  background-color: rgba(251, 191, 36, 0.12) !important;
}

.spec-table tr.fill-gray {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

.spec-table tr.fill-gray:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Add Row Button Area */
.editor-table-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 1rem;
}

/* Footer Status Bar */
.app-footer {
  background-color: var(--bg-panel-solid);
  border-top: 1px solid var(--bg-panel-border);
  padding: 0.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-dot.green {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.yellow {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-content {
  width: 450px;
  max-width: 90vw;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.style-toggle-buttons {
  display: flex;
  gap: 0.5rem;
}

.style-btn {
  flex: 1;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.style-btn:hover {
  background-color: var(--input-border);
}

.style-btn.active {
  background-color: var(--accent-light);
  border-color: var(--accent);
  color: var(--text-main);
}

.style-btn i {
  width: 0.875rem;
  height: 0.875rem;
}

/* Color & Fill Picker grid */
.color-picker-grid,
.fill-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.color-btn,
.fill-btn {
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--btn-color, var(--text-main));
  padding: 0.45rem 0.25rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.color-btn:hover,
.fill-btn:hover {
  border-color: var(--text-muted);
}

.color-btn.active,
.fill-btn.active {
  border-color: var(--accent);
  background-color: var(--accent-light);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.2);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
  background: var(--input-border);
  border-radius: var(--radius-sm);
}

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

/* Responsive adjustment */
@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--bg-panel-border);
  }

  .editor-panel {
    max-height: none;
  }
}