/* --- CONFIGURATION & VARIABLES --- */
:root {
    /* Mappings for CSSLib */
    --bg-app: var(--bg-color);
    --bg-card: var(--card-bg);
    --bg-modal: #1f1f25;
    --accent: var(--neon-purple);
    --accent-light: #d480ff;
    --accent-hover: #9b00d4;
    --text-main: var(--text-color);
    --text-muted: #888899;
    --danger: var(--neon-red);
    --warning: var(--neon-orange);
    --radius: 4px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --input-bg: #1a1f24;
}

/* --- HEADER --- */
.csslib-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 20px 5%;
    background: rgba(5, 10, 14, 0.9);
    backdrop-filter: blur(15px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(189, 0, 255, 0.2);
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 2;
    flex-wrap: wrap;
}

.logo {
    font-family: var(--cyber-font);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    margin-right: 10px;
}

/* --- SEARCH BAR --- */
.bars-container {
    display: flex;
    gap: 15px;
    flex: 1;
    min-width: 300px;
}

.input-wrapper {
    position: relative;
    flex: 1;
}

.icon-left {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.std-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid #3a3a45;
    padding: 10px 10px 10px 40px;
    border-radius: 50px;
    color: white;
    outline: none;
    transition: 0.3s;
    font-size: 0.9rem;
    height: 42px;
    font-family: var(--code-font);
}

.std-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(189, 0, 255, 0.2);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    background: var(--input-bg);
    color: var(--text-main);
    border: 1px solid #3a3a45;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-family: var(--ui-font);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    background: #3a3a45;
    transform: translateY(-1px);
    border-color: var(--accent);
}

.btn-primary {
    background: rgba(189, 0, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 15px var(--accent);
}

.btn-warning {
    border-color: var(--warning);
    color: var(--warning);
    background: transparent;
}

.btn-warning:hover {
    background: rgba(255, 107, 0, 0.1);
    box-shadow: 0 0 10px var(--warning);
}

/* --- GRID CONTAINER --- */
.csslib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 30px;
    padding: 30px 5%;
}

/* --- CARD STYLE --- */
.csslib-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), border 0.3s;
    display: flex;
    flex-direction: column;
    border: 1px solid #2a2a33;
    height: 480px;
}

.csslib-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(189, 0, 255, 0.2);
}

.csslib-card-preview {
    flex: 1;
    background: #050505;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111),
        linear-gradient(45deg, #111 25%, transparent 25%, transparent 75%, #111 75%, #111);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

.csslib-card-info {
    padding: 15px;
    background: #15151a;
    border-top: 1px solid #2a2a33;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 10px;
}

.csslib-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--accent);
    font-family: var(--code-font);
}

/* Tags in Card */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 5px;
}

.tag-pill {
    background: rgba(189, 0, 255, 0.1);
    color: var(--accent-light);
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 2px;
    border: 1px solid rgba(189, 0, 255, 0.3);
    font-weight: 600;
    font-family: var(--code-font);
}

/* Notes in Card */
.card-notes-preview {
    background: #1f1f25;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    height: 50px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    border: 1px dashed #333;
}

.card-notes-preview.empty {
    font-style: italic;
    opacity: 0.5;
    border: none;
    padding: 0;
    height: auto;
    display: none;
}

.csslib-card-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.btn-icon {
    background: transparent;
    border: 1px solid #3a3a45;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    flex: 1;
    transition: 0.2s;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--code-font);
}

.btn-icon:hover {
    background: #3a3a45;
    color: white;
    border-color: var(--accent);
}

.btn-icon.delete:hover {
    background: rgba(255, 71, 87, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

/* --- MODAL & EDITOR --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-modal);
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    border: 1px solid #333;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #2a2a33;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
    background: #15151a;
}

.modal-header-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a33;
    min-width: 400px;
}

.preview-container {
    flex: 1;
    background: #000;
    position: relative;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    background: #15151a;
    border-bottom: 1px solid #2a2a33;
}

.tab {
    padding: 12px 25px;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    transition: 0.2s;
    font-family: var(--code-font);
}

.tab:hover {
    color: #fff;
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: #1f1f25;
}

.code-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.code-area {
    flex: 1;
    background: #1a1a20;
    color: #d4d4d4;
    border: none;
    padding: 20px;
    resize: none;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
    display: none;
}

.code-area.active {
    display: block;
}

#csslib-code-notes {
    font-family: 'Inter', sans-serif;
    color: #eee;
}

/* SMART TWEAKS PANEL */
.tweaks-panel {
    width: 340px;
    background: #15151a;
    border-left: 1px solid #2a2a33;
    overflow-y: auto;
    padding: 15px;
    display: none;
}

.tweaks-panel.active {
    display: block;
}

.tweak-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--accent);
    margin: 20px 0 10px 0;
    letter-spacing: 1px;
    border-bottom: 1px solid #2a2a33;
    padding-bottom: 5px;
    font-weight: bold;
    font-family: var(--code-font);
}

.tweak-section-title:first-child {
    margin-top: 0;
}

.tweak-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
    background: #1f1f25;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #2a2a33;
}

/* Container pour les multi-couleurs (gradients) */
.multi-color-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
    background: #15151a;
    padding: 5px;
    border-radius: 4px;
}

.color-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #555;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-wrapper:hover {
    transform: scale(1.2);
    border-color: #fff;
    z-index: 2;
}

.tweak-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.tweak-label {
    font-size: 0.8rem;
    color: #ccc;
    font-weight: 600;
    font-family: monospace;
    word-break: break-all;
}

.tweak-value-display {
    font-size: 0.75rem;
    color: var(--accent-light);
    font-family: monospace;
}

/* Inputs masqués mais fonctionnels */
input[type="color"] {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    padding: 0;
    margin: 0;
    cursor: pointer;
    opacity: 0;
}

/* Color visualizer background */
.color-dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

select.tweak-select {
    width: 100%;
    background: #2a2a33;
    border: 1px solid #3a3a45;
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    font-family: var(--code-font);
}

select.tweak-select:hover {
    border-color: var(--text-muted);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    outline: none;
    margin-top: 5px;
    display: block;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* Preview Area */
#csslib-preview-host {
    width: 100%;
    height: 100%;
}

.modal-footer {
    padding: 15px;
    border-top: 1px solid #2a2a33;
    background: #15151a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.footer-right {
    display: flex;
    gap: 10px;
}

input.title-input {
    background: transparent;
    border: none;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    outline: none;
    width: 100%;
    border-bottom: 1px solid #333;
    transition: border 0.3s;
    padding-bottom: 5px;
    font-family: var(--code-font);
}

input.title-input:focus {
    border-color: var(--accent);
}

input.tags-input {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    outline: none;
    width: 100%;
    border-bottom: 1px solid #333;
    transition: border 0.3s;
    padding-bottom: 5px;
    font-family: var(--code-font);
}

input.tags-input:focus {
    border-color: var(--accent);
    color: #fff;
}

/* Mobile */
@media (max-width: 800px) {
    .csslib-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .header-left {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

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

    .modal-body {
        flex-direction: column-reverse;
    }

    .editor-container {
        height: 60%;
        border-right: none;
        border-top: 1px solid #333;
        min-width: auto;
    }

    .preview-container {
        height: 40%;
    }

    .code-wrapper {
        flex-direction: column;
    }

    .tweaks-panel {
        width: 100%;
        height: 150px;
        border-left: none;
        border-top: 1px solid #333;
    }
}

#csslib-toast {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--accent);
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 12px 24px;
    position: fixed;
    z-index: 2000;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 20px rgba(189, 0, 255, 0.4);
    font-weight: 600;
    font-family: var(--code-font);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#csslib-toast.show {
    visibility: visible;
    animation: fadein 0.4s forwards, fadeout 0.4s 2.5s forwards;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeout {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* --- SEARCH TAG BUTTON & DROPDOWN --- */
.btn-icon-large {
    background: transparent;
    border: 1px solid #3a3a45;
    color: var(--text-muted);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-icon-large:hover {
    background: #3a3a45;
    color: var(--accent);
    border-color: var(--accent);
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.2s;
}

.clear-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.tag-dropdown {
    position: absolute;
    top: 50px;
    left: 0;
    width: 250px;
    background: #1a1f24;
    border: 1px solid #3a3a45;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    padding: 5px;
    animation: fadeIn 0.2s ease;
}

.tag-dropdown.active {
    display: block;
}

.tag-option {
    padding: 8px 12px;
    cursor: pointer;
    color: #ccc;
    font-family: var(--code-font);
    font-size: 0.85rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.tag-option:hover {
    background: rgba(189, 0, 255, 0.1);
    color: var(--accent);
}

.tag-option i {
    font-size: 0.7rem;
    opacity: 0.5;
}

/* Scrollbar for dropdown */
.tag-dropdown::-webkit-scrollbar {
    width: 6px;
}

.tag-dropdown::-webkit-scrollbar-track {
    background: #15151a;
}

.tag-dropdown::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.tag-dropdown::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}