/* Album Rating Generator - Modern UI Styles */

:root {
    --canvas-scale: 0.5; /* Will be set by JS */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

/* Main layout */
main {
    display: flex;
    gap: 30px;
    padding: 20px;
    height: 100vh;
    align-items: flex-start;
}

/* Canvas container - scales down the canvas visually */
#canvas-container {
    flex-shrink: 0;
    transform: scale(var(--canvas-scale));
    transform-origin: top left;
    /* These will be set by JS based on actual canvas size */
}

canvas {
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: block;
}

/* Editor Panel */
.editor-panel {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 28px;
    width: 550px;
    height: calc(100vh - 40px);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.editor-panel::-webkit-scrollbar {
    width: 8px;
}

.editor-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.editor-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.editor-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Panel Header */
.panel-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-header h2 {
    color: #fff;
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 6px 0;
    letter-spacing: -0.5px;
}

.panel-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    margin: 0;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Inputs */
.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(138, 180, 248, 0.5);
    box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' fill-opacity='0.5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Position Controls */
.position-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: nowrap;
}

.position-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-weight: 500;
    min-width: 12px;
}

.position-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    user-select: none;
}

.position-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(138, 180, 248, 0.5);
}

.position-btn:active {
    background: rgba(138, 180, 248, 0.3);
}

.position-input {
    width: 48px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: #fff;
    font-size: 11px;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

.position-input::-webkit-outer-spin-button,
.position-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.position-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(138, 180, 248, 0.5);
}

.position-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Image input with upload button */
.image-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.image-input-row .form-input {
    flex: 1;
}

.image-upload-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-upload-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(138, 180, 248, 0.5);
}

.hidden-file-input {
    display: none;
}

/* Slider */
.slider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.slider-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    min-width: 115px;
    flex-shrink: 0;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.form-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

.form-slider:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.form-slider:disabled::-webkit-slider-thumb {
    background: #666;
    cursor: not-allowed;
}

.form-slider:disabled::-moz-range-thumb {
    background: #666;
    cursor: not-allowed;
}

.form-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #8ab4f8, #669df6);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(138, 180, 248, 0.4);
    transition: transform 0.2s ease;
}

.form-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.form-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #8ab4f8, #669df6);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(138, 180, 248, 0.4);
}

.slider-value {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Section Divider */
.section-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 24px 0;
}

/* Section Title */
.section-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: linear-gradient(135deg, #8ab4f8, #669df6);
    border-radius: 2px;
}

/* Track Container */
.track-container {
    max-height: 650px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 8px;
}

.track-container::-webkit-scrollbar {
    width: 6px;
}

.track-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.track-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Track Row */
.track-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    position: relative;
    flex-wrap: wrap;
    cursor: grab;
    min-height: 48px; /* Ensure consistent height */
}

.track-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.track-row.dragging {
    opacity: 0.5;
    cursor: grabbing;
    transform: scale(0.95);
}

.track-row.drag-over {
    background: rgba(138, 180, 248, 0.15);
    border: 2px dashed rgba(138, 180, 248, 0.5);
    transform: translateY(-2px);
}

.track-drag-handle {
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    cursor: grab;
    user-select: none;
    line-height: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.track-drag-handle:hover {
    color: rgba(255, 255, 255, 0.6);
}

.track-row:active .track-drag-handle {
    cursor: grabbing;
}

.track-number {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    font-weight: 500;
    min-width: 24px;
    height: 32px;
    display: flex;
    align-items: center;
}

.track-title-input {
    flex: 1;
    padding: 0 10px;
    height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
    line-height: 32px;
}

.track-title-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(138, 180, 248, 0.4);
}

.track-title-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.track-grade-select {
    padding: 0 30px 0 10px;
    height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23ffffff' fill-opacity='0.5' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s ease;
    line-height: 32px;
}

.track-grade-select:focus {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(138, 180, 248, 0.4);
}

.track-grade-select option {
    background: #1a1a2e;
}

.track-text-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(138, 180, 248, 0.15);
    border: none;
    border-radius: 6px;
    color: #8ab4f8;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.track-text-btn:hover {
    background: rgba(138, 180, 248, 0.25);
}

.track-text-input-container {
    width: 100%;
    margin-top: 6px;
    flex-basis: 100%;
    order: 999;
}

.track-text-input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.4);
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    outline: none;
    transition: all 0.2s ease;
}

.track-text-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(138, 180, 248, 0.6);
}

.track-text-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.track-remove-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.15);
    border: none;
    border-radius: 6px;
    color: #ef4444;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.track-remove-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Buttons */
.btn {
    padding: 12px 20px;
    height: auto;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

.btn-blue {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: #fff;
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.3);
}

.btn-blue:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(96, 165, 250, 0.4);
}

.btn-purple {
    background: linear-gradient(135deg, #c084fc, #a855f7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(192, 132, 252, 0.3);
}

.btn-purple:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(192, 132, 252, 0.4);
}

.btn-orange {
    background: linear-gradient(135deg, #fb923c, #f97316);
    color: #fff;
    box-shadow: 0 4px 15px rgba(251, 146, 60, 0.3);
}

.btn-orange:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(251, 146, 60, 0.4);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Button Grid */
.button-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.button-row {
    display: flex;
    gap: 10px;
}

.button-row .btn {
    flex: 1;
}

/* File Input */
.file-input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-input-label:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.7);
}

.file-input-label svg {
    width: 20px;
    height: 20px;
    opacity: 0.6;
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

/* Drag and Drop Overlay */
.drag-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
}

.drag-overlay.active {
    display: flex;
}

.drag-overlay-content {
    text-align: center;
    color: #fff;
}

.drag-overlay-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #8ab4f8, #669df6);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drag-overlay-icon svg {
    width: 40px;
    height: 40px;
    color: #fff;
}

.drag-overlay h3 {
    font-size: 24px;
    margin: 0 0 8px 0;
}

.drag-overlay p {
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

/* Color Customization Section */
.color-section {
    margin-top: 8px;
}

.color-section-header {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 0;
    transition: color 0.2s ease;
    user-select: none;
}

.color-section-header:hover {
    color: #fff;
}

.color-toggle {
    font-size: 10px;
    margin-right: 4px;
    transition: transform 0.2s ease;
}

.color-content {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    padding-top: 12px;
}

.color-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    pointer-events: none;
}

.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    margin-bottom: 8px;
}

.color-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.color-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    font-weight: 500;
}

.color-picker {
    width: 50px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.color-picker::-moz-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 400px;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
}

/* Size Adjust Panel */
#size-adjust-panel {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(40, 40, 40, 0.95);
    padding: 15px 25px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    gap: 15px;
}

#size-adjust-panel .label {
    color: white;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

#size-adjust-panel .btn-control {
    width: 40px;
    height: 40px;
    font-size: 24px;
    background: #444;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#size-adjust-panel .btn-control:hover {
    background: #555;
}

#size-adjust-panel .display {
    color: white;
    font-family: monospace;
    font-size: 16px;
    min-width: 60px;
    text-align: center;
}

#size-adjust-panel #size-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#size-adjust-panel #leading-container {
    display: none;
    gap: 10px;
    align-items: center;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    padding-left: 15px;
    margin-left: 5px;
}

#size-adjust-panel #custom-textbox-controls {
    display: none;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#size-adjust-panel #custom-textbox-controls .form-slider {
    width: 70px;
    height: 4px;
}

#size-adjust-panel #custom-textbox-controls .form-select {
    padding: 6px 10px;
    font-size: 12px;
    background-size: 8px;
    min-width: 90px;
}

#size-adjust-panel #custom-textbox-controls .color-picker {
    width: 36px;
    height: 28px;
}

#size-adjust-panel #custom-textbox-controls .display {
    min-width: 30px;
    font-size: 12px;
}

#size-adjust-panel #custom-textbox-controls .label {
    font-size: 12px;
}

#size-adjust-panel .btn-reset {
    background: #336688;
    margin-left: 10px;
}

#size-adjust-panel .btn-close {
    background: #883333;
    font-size: 18px;
}

.track-number-input {
    width: 40px;
    text-align: center;
    padding: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.4);
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    outline: none;
}

/* Checkbox styling */
.checkbox-input {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.checkbox-input input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #8ab4f8;
}

.checkbox-input label {
    line-height: 18px;
    margin: 0;
    padding: 0;
}

/* Responsive */
@media (max-width: 1400px) {
    .editor-panel {
        width: 340px;
        padding: 20px;
    }
}
