/* Universal rule for more consistent sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #333;
    --title-color: #2c3e50;
    --border-color: #ddd;
    --subtle-bg: #ecf0f1;
    --main-color-highlight: #3498db;
    --link-color: #2980b9;
}

body.dark-theme {
    --bg-color: #1e1e1e;
    --card-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --title-color: #ffffff;
    --border-color: #444;
    --subtle-bg: #3a3a3a;
    --main-color-highlight: #5dade2;
    --link-color: #5dade2;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    transition: background-color 0.3s, color 0.3s;
}

#theme-toggle-button {
    display: block;
    margin: 40px auto 20px auto;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: background-color 0.3s, transform 0.2s;
}
#theme-toggle-button:hover {
    transform: scale(1.1);
}

.main-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    max-width: 1200px;
    margin: auto;
}

.color-picker-main {
    flex: 1;
    min-width: 300px;
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    text-align: center;
    transition: background-color 0.3s;
    display: flex;
    flex-direction: column;
}

.wheel-wrapper {
    margin: 20px auto;
}

.wheel-container {
    position: relative;
    width: 250px;
    height: 250px;
    cursor: crosshair;
}

#color-wheel-canvas, #harmony-dots-container, #wheel-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#color-wheel-canvas {
    border-radius: 50%;
}

#harmony-dots-container, #wheel-handle {
    pointer-events: none;
}

.harmony-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--card-bg);
    box-shadow: 0 0 5px rgba(0,0,0,0.4);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#wheel-handle {
    width: 22px;
    height: 22px;
    border: 3px solid var(--card-bg);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.4);
    z-index: 5;
    transform: translate(-50%, -50%);
}

.sliders {
    margin-top: 20px;
    margin-bottom: auto;
}

.slider-group {
    margin-bottom: 15px;
}

input[type="range"] {
    width: 80%;
    cursor: pointer;
}

.color-preview-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

#color-preview {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#color-hex-value {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: monospace;
}

h1, h2 {
    color: var(--title-color);
}

.palettes-section {
    flex: 1;
    min-width: 400px;
}

#palette-title {
    text-align: right;
    font-size: 1.4rem;
    color: var(--title-color);
    margin-bottom: 15px;
    margin-top: 0;
}

#palette-title span {
    font-family: monospace;
    background-color: var(--subtle-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: -1px;
}

.tab-button {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Vazirmatn', sans-serif;
    color: var(--text-color);
    transition: background-color 0.3s;
}

.tab-button.active {
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-bg);
    font-weight: bold;
}

.tab-content-container {
    background: var(--card-bg);
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: background-color 0.3s, border-color 0.3s;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.palette h3 {
    display: none;
}

.palette-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    align-items: center;
}

.color-box {
    flex-grow: 1;
    height: 100px;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 8px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    position: relative;
    border: 4px solid transparent;
    order: 2;
}

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

.color-box.main-color {
    order: 1;
    border: 4px solid var(--main-color-highlight);
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    transform: scale(1.1);
    position: relative;
    z-index: 2;
}

.color-box.selected {
    box-shadow: 0 0 0 4px var(--main-color-highlight), 0 5px 20px rgba(0,0,0,.25);
    transform: scale(1.15) !important;
}

.copy-feedback-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.ai-palette-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    text-align: center;
    margin-top: 30px;
    /* This new line makes it align perfectly with the box above */
    border: 1px solid var(--border-color);
}

.ai-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

.selected-color-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background-color: #eee;
    transition: background-color 0.3s;
}

#ai-generate-button {
    padding: 10px 20px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

#ai-generate-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.7;
}

#ai-generate-button.loading {
    background-color: #f39c12;
    cursor: wait;
}

.ai-result-container {
    margin-top: 25px;
    padding: 15px;
    min-height: 120px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-result-container .placeholder {
    opacity: 0.6;
}

footer {
    width: 100%;
    text-align: center;
    padding: 20px 0;
    color: var(--text-color);
    opacity: 0.8;
}

footer a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .main-container {
        flex-direction: column;
        gap: 20px;
    }

    .color-picker-main {
        padding: 15px;
    }

    .wheel-container {
        max-width: 280px;
    }

    .palettes-section {
        overflow-x: hidden;
    }
    
    .tabs {
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .color-box {
        min-width: 60px;
        height: 80px;
    }
    .color-box.main-color {
        height: 90px;
    }
    h2#palette-title {
       display: none;
    }
}