/* css/styles.css */

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4361EE;
    --primary-dark: #1F3BC0;
    --secondary: #7209B7;
    --light-1: #FFFFFF;
    --light-2: #EFF1FE;
    --light-3: #D5DBFB;
    --dark-1: #101C5E;
    --dark-2: #2D3979;
    --dark-3: #474E6B;
    --bg-sidebar: #FFFFFF;
    --bg-preview: #F5F5F5;
    --text-primary: #212529;
    --text-secondary: #6C757D;
    --border: #DEE2E6;
    --shadow: rgba(0, 0, 0, 0.1);
    --current-hue: 229;
    --current-saturation: 83%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-preview);
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar - 40% ===== */
.sidebar {
    width: 40%;
    background: var(--bg-sidebar);
    padding: 2rem;
    overflow-y: auto;
    box-shadow: 2px 0 10px var(--shadow);
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(-100%);
    width: 0;
}

/* ===== Header ===== */
.app-header {
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.app-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== API Status Indicator ===== */
.api-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: var(--light-2);
    border-radius: 1rem;
    font-size: 0.75rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #DC3545;
    transition: all 0.3s;
}

.api-status.online .status-dot {
    background: #28A745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.api-status.checking .status-dot {
    background: #FFC107;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.analyze-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light-2);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ===== Sections ===== */
section {
    margin-bottom: 2rem;
}

section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* ===== Business Selector ===== */
.business-selector label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.business-selector select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.business-selector select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Color Controls ===== */
.color-group {
    margin-bottom: 1.5rem;
}

.color-input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: relative;
}

.color-swatch {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background-color: var(--primary);
}

.color-swatch:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

.color-input-group input[type="text"] {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: monospace;
    text-transform: uppercase;
}

.color-input-group input[type="color"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* ===== Add Secondary Button ===== */
.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    transition: all 0.2s;
}

.btn-text:hover {
    color: var(--primary-dark);
    transform: translateX(5px);
}

/* ===== Sliders with colored backgrounds ===== */
.sliders label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.sliders input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    margin-bottom: 1rem;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.hue-slider {
    background: linear-gradient(to right, 
        hsl(0, 100%, 50%) 0%, 
        hsl(60, 100%, 50%) 16.66%, 
        hsl(120, 100%, 50%) 33.33%, 
        hsl(180, 100%, 50%) 50%, 
        hsl(240, 100%, 50%) 66.66%, 
        hsl(300, 100%, 50%) 83.33%, 
        hsl(360, 100%, 50%) 100%
    );
}

.saturation-slider {
    background: linear-gradient(to right, 
        hsl(var(--current-hue), 0%, 50%), 
        hsl(var(--current-hue), 100%, 50%)
    );
}

.lightness-slider {
    background: linear-gradient(to right, 
        hsl(var(--current-hue), var(--current-saturation), 0%), 
        hsl(var(--current-hue), var(--current-saturation), 50%),
        hsl(var(--current-hue), var(--current-saturation), 100%)
    );
}

.sliders input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sliders input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.sliders input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.btn-secondary {
    background: var(--light-2);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--light-3);
}

/* ===== Palette Display ===== */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.palette-item {
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.palette-item:hover {
    transform: translateY(-2px);
}

.palette-item.highlighted {
    transform: translateY(-4px) scale(1.05);
}

.palette-color {
    width: 100%;
    height: 60px;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.palette-color:hover {
    transform: scale(1.05);
}

.palette-color.locked::after {
    content: '🔒';
    font-size: 1.25rem;
}

.palette-copy {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    padding: 0.25rem;
    border-radius: 0.25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-item:hover .palette-copy {
    opacity: 1;
}

.palette-copy:hover {
    background: white;
    transform: scale(1.1);
}

.palette-copy svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-secondary);
}

.palette-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.palette-hex {
    font-size: 0.625rem;
    font-family: monospace;
    color: var(--text-secondary);
}

/* ===== Actions ===== */
.actions {
    display: flex;
    gap: 0.75rem;
}

.actions .btn-primary {
    flex: 1;
}

/* ===== Color Tooltip ===== */
.color-tooltip {
    position: fixed;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 4px 12px var(--shadow);
    display: none;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    pointer-events: none;
}

.color-tooltip.show {
    display: flex;
}

.tooltip-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.tooltip-hex {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.url-input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.url-input-group input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.url-input-group button {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.url-input-group button:hover {
    background: var(--primary-dark);
}

/* ===== Analysis Progress ===== */
.analysis-progress {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--light-1);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: none;
}

.analysis-progress.show {
    display: block;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.progress-step.active {
    opacity: 1;
    color: var(--primary);
}

.progress-step.complete {
    opacity: 1;
    color: #28A745;
}

.progress-step::before {
    content: '○';
    font-size: 1rem;
}

.progress-step.active::before {
    content: '◉';
    animation: spin 1s linear infinite;
}

.progress-step.complete::before {
    content: '✓';
}

.analysis-result {
    padding: 1rem;
    background: var(--light-1);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: none;
}

.analysis-result.show {
    display: block;
}

/* ===== Preview Container - 60% ===== */
.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-preview);
    transition: all 0.3s ease;
}

.preview-container.fullscreen {
    width: 100%;
}

/* ===== Preview Controls ===== */
.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mode-switcher {
    display: flex;
    gap: 0.5rem;
}

.mode-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.fullscreen-btn {
    padding: 0.5rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.fullscreen-btn:hover {
    background: var(--light-1);
}

/* ===== Preview Content ===== */
.preview-content {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* ===== Preview Elements ===== */
[data-color] {
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

[data-color]:hover {
    opacity: 0.9;
}

/* ===== Preview Mockup ===== */
.preview-mockup {
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.preview-mockup > * {
    margin: 0; /* No gaps between sections */
}

/* ===== Icons ===== */
.icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.icon-lg {
    width: 48px;
    height: 48px;
}

/* ===== Animations ===== */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.slide-up {
    animation: slideUp 0.8s ease-out;
}

.scale-in {
    animation: scaleIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from { 
        opacity: 0;
        transform: scale(0.9);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

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

/* ===== Hover Effects ===== */
.hover-lift {
    transition: all 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.hover-scale {
    transition: all 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===== Dashboard Mockup ===== */
.dashboard-mockup {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.dashboard-mockup:hover {
    transform: scale(1.02);
}

.dashboard-header {
    padding: 1rem;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.window-controls {
    display: flex;
    gap: 0.5rem;
}

.window-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.window-dot:nth-child(1) { background: #FF5F57; }
.window-dot:nth-child(2) { background: #FFBD2E; }
.window-dot:nth-child(3) { background: #28CA42; }

/* ===== Loading State ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--light-2);
    border-radius: 50%;
}