/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #C62E2E;
    --secondary-color: #1e1e1e;
    --accent-color: #C1E172;
    --background-color: #f8f9fa;
    --text-color: #1e1e1e;
    --text-muted: #6c757d;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s ease;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    font-size: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 700;
    font-size: 1.25rem;
    transition: var(--transition);
}

.logo:hover {
    opacity: 0.8;
}

.logo-text {
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.95rem;
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, rgba(198, 46, 46, 0.05) 0%, rgba(193, 225, 114, 0.05) 100%);
    padding: 4rem 0;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-icon {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-muted);
    line-height: 1.8;
}

/* Main Content */
.main-content {
    padding: 3rem 0;
}

.tool-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 3rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 3px dashed #dee2e6;
    border-radius: var(--border-radius);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(198, 46, 46, 0.02);
}

.upload-area.dragover {
    border-color: var(--accent-color);
    background-color: rgba(193, 225, 114, 0.1);
}

.upload-content {
    user-select: none;
}

.upload-icon {
    margin-bottom: 1rem;
}

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.upload-subtitle {
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.upload-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Preview Section */
.preview-section {
    margin-bottom: 2rem;
}

.preview-container {
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    background: #fafbfc;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.preview-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-actions {
    display: flex;
    gap: 0.75rem;
}

.image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background: white;
}

#imageCanvas {
    max-width: 100%;
    max-height: 500px;
    display: block;
    border-radius: var(--border-radius-sm);
}

.color-picker-cursor {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid white;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    z-index: 10;
}

.color-picker-cursor::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: white;
    border: 1px solid #333;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.picked-color-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--border-radius-sm);
    margin-top: 1rem;
    box-shadow: var(--shadow);
}

.picked-color-preview {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-sm);
    border: 2px solid #dee2e6;
}

.picked-color-details {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#pickedColorHex {
    font-family: 'Courier New', monospace;
    font-size: 1.125rem;
    font-weight: 600;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1.5rem;
    background: white;
    border-radius: var(--border-radius);
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.control-group {
    flex: 1;
    min-width: 200px;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

#colorCountValue {
    color: var(--primary-color);
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #dee2e6;
    outline: none;
 }

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Results Section */
.results-section {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.color-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.color-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.color-preview {
    height: 120px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.color-preview:hover {
    filter: brightness(1.1);
}

.color-info {
    padding: 1rem;
}

.color-value {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-formats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.format-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.format-label {
    font-weight: 500;
}

.format-value {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.copy-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
}

.copy-btn:hover {
    background: rgba(198, 46, 46, 0.1);
}

.copy-btn.copied {
    color: var(--accent-color);
}

/* History Section */
.history-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #dee2e6;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.palette-history {
    display: grid;
    gap: 1rem;
}

.history-item {
    background: #fafbfc;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    transition: var(--transition);
}

.history-item:hover {
    border-color: var(--primary-color);
    background: white;
}

.history-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.history-date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.history-colors {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.history-color {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: var(--transition);
}

.history-color:hover {
    transform: scale(1.1);
}

/* Button Styles */
.btn-primary,
.btn-secondary,
.btn-text,
.btn-icon {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #a82525;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(198, 46, 46, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--text-color);
    border: 2px solid #dee2e6;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
}

.btn-text:hover {
    color: var(--primary-color);
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--primary-color);
}

.btn-icon:hover {
    background: rgba(198, 46, 46, 0.1);
}

/* Features Section */
.features-section {
    padding: 4rem 0;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--text-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    text-align: center;
    padding: 2rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.feature-description {
    color: var(--text-muted);
    line-height: 1.7;
}

/* How To Section */
.how-to-section {
    padding: 4rem 0;
    background: white;
    border-radius: var(--border-radius);
    margin: 3rem 0;
}

.steps-container {
    display: grid;
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.step-card {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.step-number {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.step-content {
    flex: 1;
}

.step-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.step-description {
    color: var(--text-muted);
    line-height: 1.7;
}

/* CTA Section */
.cta-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #a82525 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 4rem 3rem;
    margin: 4rem 0;
}

.cta-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.cta-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.cta-description {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cta-section .btn-primary {
    background: white;
    color: var(--primary-color);
}

.cta-section .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cta-section .btn-secondary {
    background: transparent;
    border-color: white;
    color: white;
}

.cta-section .btn-secondary:hover {
    background: white;
    color: var(--primary-color);
}

.cta-visual {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* FAQ Section */
.faq-section {
    padding: 4rem 0;
}

.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    background: white;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: white;
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: left;
    color: var(--text-color);
    transition: var(--transition);
}

.faq-question:hover {
    background: #fafbfc;
}

.faq-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-answer p {
    padding: 0 1.5rem 1.5rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.faq-item.active .faq-answer {
    max-height: 500px;
}

/* Content Section */
.content-section {
    padding: 4rem 0;
}

.content-article {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.content-article h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.content-article h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.content-article p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    color: var(--text-muted);
}

.content-article strong {
    color: var(--text-color);
    font-weight: 600;
}

/* Footer */
.footer {
    background: var(--secondary-color);
    color: white;
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 3rem;
    margin-bottom: 2rem;
}

.footer-brand {
    max-width: 300px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 1.25rem;
}

.footer-tagline {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
}

.footer-links {
    display: contents;
}

.footer-column h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.footer-column a {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    margin-bottom: 0.75rem;
    transition: var(--transition);
    font-size: 0.95rem;
}

.footer-column a:hover {
    color: white;
    padding-left: 4px;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: var(--transition);
    margin-bottom: 0;
}

.social-links a:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
    padding-left: 0;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

.footer-love {
    color: rgba(255, 255, 255, 0.6);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--secondary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: #28a745;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        gap: 1rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .tool-container {
        padding: 1.5rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .controls-panel {
        flex-direction: column;
    }

    .preview-actions,
    .results-actions {
        flex-direction: column;
        width: 100%;
    }

    .preview-actions button,
    .results-actions button {
        width: 100%;
    }

    .color-palette {
        grid-template-columns: 1fr;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .cta-content {
        grid-template-columns: 1fr;
    }

    .cta-visual {
        display: none;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .content-article {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.75rem;
    }

    .cta-title {
        font-size: 1.5rem;
    }

    .cta-buttons {
        flex-direction: column;
    }

    .cta-buttons .btn-primary,
    .cta-buttons .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}