:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --code-bg: #0b1121;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
}

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

/* Big Color Display area */
.color-display {
    height: 300px;
    background-color: #6366F1; /* Default */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    color: white;
}

#display-hex {
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 2px;
}

#display-rgb {
    font-size: 1.5rem;
    opacity: 0.9;
}

/* Main Content area */
.main-content {
    flex: 1;
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 25px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

/* Inputs */
.flex-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

input[type="color"] {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background-color: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 12px; }

input[type="text"], input[type="number"] {
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1rem;
    outline: none;
    width: 100%;
    font-family: 'Fira Code', monospace;
}
input[type="text"]:focus, input[type="number"]:focus {
    border-color: #6366F1;
}

.rgb-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.rgb-inputs .input-group {
    display: flex;
    flex-direction: column;
}

.rgb-inputs label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-align: center;
}

.rgb-inputs input {
    text-align: center;
}

.btn-random {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background-color: rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-random:hover {
    background-color: rgba(255,255,255,0.2);
}

/* Code Converter */
.code-block {
    margin-bottom: 15px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.code-header {
    background-color: rgba(0,0,0,0.3);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    font-size: 1rem;
}
.btn-copy:hover { color: var(--text-primary); }

pre {
    background-color: var(--code-bg);
    padding: 15px;
    color: #a5b4fc;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    overflow-x: auto;
}

/* Palettes */
.palette-container {
    margin-bottom: 25px;
}

.palette {
    display: flex;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.color-swatch {
    flex: 1;
    cursor: pointer;
    transition: flex 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    color: transparent;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Fira Code', monospace;
}

.color-swatch:hover {
    flex: 1.5;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Swatch Selected State */
.color-swatch {
    position: relative;
}
.color-swatch.selected {
    border: 3px solid white;
    transform: scale(0.95);
    z-index: 2;
    border-radius: 8px;
}
.color-swatch.selected::after {
    content: '\f00c';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    color: white;
    font-size: 1.2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Tooltip */
.color-swatch[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: #000;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    z-index: 10;
}
.color-swatch[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* Selection Card */
.selection-card {
    display: flex;
    flex-direction: column;
}
.selection-info {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.selection-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
}
#selected-count {
    font-weight: 600;
    font-size: 1.1rem;
    color: #a5b4fc;
}
.btn-clear-selection {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
}
.btn-clear-selection:hover {
    color: #fca5a5;
}
.btn-convert {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background-color: #6366F1;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-convert:disabled {
    background-color: #334155;
    color: #94a3b8;
    cursor: not-allowed;
}
.btn-convert:not(:disabled):hover {
    background-color: #4f46e5;
}

/* Modal Overlay & Content */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s ease;
    backdrop-filter: blur(5px);
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.modal-content {
    background: var(--card-bg);
    width: 90%;
    max-width: 700px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: translateY(30px);
    transition: 0.3s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-overlay.show .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
    margin: 0;
}
.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: 0.2s;
}
.btn-close-modal:hover {
    color: white;
}
.modal-body {
    padding: 25px;
    overflow-y: auto;
}

/* Toast */
.toast {
    position: fixed;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #10b981;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 600;
    transition: bottom 0.3s ease;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.toast.show {
    bottom: 30px;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}
