/* CSS Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-primary: #6366f1;
    --accent-hover: #818cf8;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --success-color: #10b981;
    --error-color: #ef4444;
    --transition-speed: 0.2s;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

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

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Controls Section */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.control-group select {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 150px;
    transition: border-color var(--transition-speed);
}

.control-group select:hover,
.control-group select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #a855f7);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.25rem;
}

/* Palette Container */
.palette-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    min-height: 300px;
}

/* Color Card */
.color-card {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    min-height: 300px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    display: flex;
    flex-direction: column;
}

.color-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.color-card.locked {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.color-preview {
    flex: 1;
    min-height: 200px;
    cursor: pointer;
    position: relative;
    transition: filter var(--transition-speed);
}

.color-preview:hover::after {
    content: 'Click to copy';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.color-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-hex {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    text-align: center;
    transition: background var(--transition-speed);
}

.color-hex:hover {
    background: var(--border-color);
}

.color-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.color-action-btn {
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition-speed);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.color-action-btn.locked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

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

/* Actions Section */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

/* Saved Palettes Section */
.saved-palettes {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.saved-palettes h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-primary);
}

.saved-palettes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.saved-palette-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform var(--transition-speed);
}

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

.saved-palette-colors {
    display: flex;
    height: 60px;
}

.saved-palette-color {
    flex: 1;
    cursor: pointer;
    position: relative;
}

.saved-palette-color:hover::after {
    content: attr(data-color);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    white-space: nowrap;
    z-index: 10;
}

.saved-palette-info {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.saved-palette-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.saved-palette-actions {
    display: flex;
    gap: 0.5rem;
}

.saved-palette-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.saved-palette-btn:hover {
    background: var(--border-color);
}

.saved-palette-btn.delete:hover {
    background: var(--error-color);
    border-color: var(--error-color);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color var(--transition-speed);
}

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

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

.modal-body textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    resize: vertical;
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

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

.toast.success {
    border-color: var(--success-color);
}

.toast.error {
    border-color: var(--error-color);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

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

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.footer a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .logo-img {
        width: 36px;
        height: 36px;
    }

    .controls {
        padding: 1rem;
    }

    .control-group select {
        min-width: 120px;
    }

    .palette-container {
        gap: 0.75rem;
    }

    .color-card {
        min-width: 100px;
        min-height: 250px;
    }

    .color-preview {
        min-height: 150px;
    }

    .color-info {
        padding: 0.75rem;
    }

    .color-hex {
        font-size: 0.75rem;
    }

    .actions {
        gap: 0.75rem;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .saved-palettes-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
    }

    .control-group select {
        width: 100%;
    }

    .btn-primary {
        width: 100%;
    }

    .palette-container {
        flex-direction: column;
    }

    .color-card {
        max-width: none;
        min-height: 120px;
        flex-direction: row;
    }

    .color-preview {
        min-height: auto;
        min-width: 100px;
    }

    .color-info {
        flex: 1;
        justify-content: center;
    }

    .color-preview:hover::after {
        display: none;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        width: 100%;
    }

    .modal-content {
        max-height: 90vh;
    }

    .modal-body textarea {
        min-height: 200px;
    }
}

/* Animation for color cards */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.color-card {
    animation: fadeIn 0.3s ease forwards;
}

.color-card:nth-child(1) { animation-delay: 0s; }
.color-card:nth-child(2) { animation-delay: 0.05s; }
.color-card:nth-child(3) { animation-delay: 0.1s; }
.color-card:nth-child(4) { animation-delay: 0.15s; }
.color-card:nth-child(5) { animation-delay: 0.2s; }
.color-card:nth-child(6) { animation-delay: 0.25s; }
.color-card:nth-child(7) { animation-delay: 0.3s; }

/* Keyboard hint */
.keyboard-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 1rem;
}

.keyboard-hint kbd {
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.875rem;
}
