/* =========================================
   ICON DETAIL MODAL STYLES
   Shared between index.html, search.html, icons.html
   ========================================= */

.icon-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-detail-modal.hidden {
    display: none;
}

/* Modal closing animation */
.icon-detail-modal.modal-closing {
    animation: fadeOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.icon-detail-modal.modal-closing .modal-content {
    animation: popOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes popOut {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    100% {
        transform: scale(0.95) translateY(10px);
        opacity: 0;
    }
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease-out;
    /* Neo-Brutalism: No backdrop-filter */
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: #18181b;
    border-radius: 12px;
    border: 3px solid #000000;
    /* Neo-Brutalism: Hard black shadow */
    box-shadow: 8px 8px 0px 0px #000000 !important;
    z-index: 1;
    animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}

.modal-content.editor-active {
    max-width: 1200px;
}

@keyframes popIn {
    0% {
        transform: scale(0.92) translateY(20px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    font-size: 1.2rem;
    color: #a1a1aa;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Hide close button in editor view */
.modal-content.editor-active .modal-close-btn {
    display: none;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 450px;
}

.modal-icon-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    padding: 3rem 2rem;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-icon-preview.dark-mode {
    background: #27272A;
}

.modal-theme-toggle {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a1a1aa;
    transition: all 0.2s;
}

.modal-theme-toggle:hover {
    background: #6366f1;
    color: white;
    transform: scale(1.1);
}

.modal-icon-display {
    font-size: 12rem;
    color: #18181b;
    transition: all 0.3s;
}

.modal-icon-preview.dark-mode .modal-icon-display {
    color: #e2e8f0;
}

/* Theme toggle button styles for light/dark mode */
.modal-icon-preview .modal-theme-toggle {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #52525b;
}

.modal-icon-preview.dark-mode .modal-theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a1a1aa;
}

.modal-icon-details {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100%;
}

.modal-icon-name {
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    color: #fafafa;
}

.modal-icon-license {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.modal-icon-subtitle {
    font-size: 0.9rem;
    color: #71717a;
    font-weight: 500;
}

.modal-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
}

.modal-collection-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    transition: all 0.2s;
}

.modal-collection-link:hover {
    color: #818cf8;
    text-decoration: underline;
}

.modal-separator {
    color: #52525b;
    font-size: 0.8rem;
}

/* Modal Actions - NEO-BRUTALISM */
.modal-actions {
    display: flex;
    gap: 0.5rem;
    background: #ffffff;
    padding: 0.4rem;
    border-radius: 8px;
    border: 2px solid #000000;
}

.modal-action-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    background-color: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-action-btn:hover {
    background-color: var(--color-brand);
    color: #000000;
    transform: translate(-1px, -1px);
    box-shadow: 2px 2px 0px 0px #000000;
}

.modal-action-btn.active {
    background-color: var(--color-brand);
    color: #000000;
    box-shadow: 2px 2px 0px 0px #000000;
}

/* Modal Code Container - NEO-BRUTALISM */
.modal-code-container {
    position: relative;
    flex: 1;
    cursor: pointer;
    background: #f8fafc;
    border-radius: 8px;
    border: 2px solid #000000;
    overflow: hidden;
    max-height: 180px;
    min-height: 80px;
    transition: all 0.15s ease;
}

.modal-code-container:hover {
    background: var(--color-brand);
    box-shadow: 3px 3px 0px 0px #000000;
    transform: translate(-1px, -1px);
}

.modal-code-scroll {
    padding: 1rem;
    padding-top: 2.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: 180px;
    min-height: 80px;
}

/* SVG/JSX/Tailwind snippets are often multi-line; allow vertical scrolling */
.modal-code-container[data-tab="svg"] .modal-code-scroll,
.modal-code-container[data-tab="jsx"] .modal-code-scroll,
.modal-code-container[data-tab="tailwind"] .modal-code-scroll {
    overflow-y: auto;
}

/* Custom scrollbar for code container */
.modal-code-scroll::-webkit-scrollbar {
    height: 6px;
}

.modal-code-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.modal-code-scroll::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 3px;
    transition: background 0.2s;
}

.modal-code-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.7);
}

.modal-code-content {
    color: #a5f3fc;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
    line-height: 1.5;
    display: block;
    pointer-events: none;
}

.modal-code-container[data-tab="svg"] .modal-code-content,
.modal-code-container[data-tab="jsx"] .modal-code-content,
.modal-code-container[data-tab="tailwind"] .modal-code-content {
    white-space: pre;
}

.modal-code-hint {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.75rem;
    color: #64748b;
    background: #1e293b;
    padding: 3px 10px;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
    transition: all 0.2s;
}

.modal-code-container:hover .modal-code-hint {
    background: #6366f1;
    color: white;
}

/* Modal SVG/PNG Actions */
.modal-svg-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.modal-svg-actions .btn-download-svg,
.modal-svg-actions .png-dropdown-wrapper {
    flex: 1;
}

.btn-edit-icon-wrapper {
    margin-top: auto;
    margin-bottom: 0.75rem;
}

.btn-edit-icon-wrapper .btn-edit-icon {
    width: 100%;
    justify-content: center;
}

.png-dropdown-wrapper {
    position: relative;
}

.btn-download-png {
    width: 100%;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 2px black solid
}

.btn-download-png:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.png-size-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #18181b;
    /* Dark background matching modal */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    display: none;
    z-index: 10001;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Light mode support if needed */
:root:not(.dark) .png-size-dropdown {
    background: #ffffff;
    border-color: #e4e4e7;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

:root:not(.dark) .png-size-option {
    color: #52525b;
}

:root:not(.dark) .png-size-option:hover {
    background: #f4f4f5;
    color: #18181b;
}

.png-size-dropdown.show {
    display: block;
    height: 315px;
    overflow: auto;
}

.png-size-option {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: #a1a1aa;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.png-size-option:hover {
    background: #3f3f46;
    color: white;
}

.btn-download-svg {
    flex: 1;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: 1px solid rgba(99, 102, 241, 0.5);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-download-svg:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.8);
}

.btn-edit-icon {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    background: transparent;
    color: #a1a1aa;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-edit-icon:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-color: #6366f1;
}

/* =========================================
   RELATED ICONS SECTION
   ========================================= */
.modal-related-section {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}

.modal-related-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.modal-related-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #a1a1aa;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.modal-related-title i {
    color: #6366f1;
    font-size: 0.75rem;
}

.modal-related-view-all {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6366f1;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-related-view-all:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
}

.modal-related-view-all i {
    font-size: 0.625rem;
    transition: transform 0.2s;
}

.modal-related-view-all:hover i {
    transform: translateX(3px);
}

.modal-related-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    row-gap: 1rem;
    max-height: 180px;
    padding: 10px;
    overflow-y: auto;

}

@media (max-width: 768px) {
    .modal-related-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.modal-related-grid::-webkit-scrollbar {
    width: 4px;
}

.modal-related-grid::-webkit-scrollbar-track {
    background: transparent;
}

.modal-related-grid::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 2px;
}

/* Related Icons - NEO-BRUTALISM */
.modal-related-icon {
    width: 100%;
    height: 125px;
    position: relative;
    background: #ffffff;
    border: 2px solid #000000;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-related-icon:hover {
    background: #ffffff;
    transform: none;
}

.modal-related-icon i {
    font-size: 2.25rem;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-related-icon:hover i {
    color: #000000;
    transform: none;
}

/* Icon name tooltip on hover */
.modal-related-icon::after {
    content: attr(title);
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 5;
}

.modal-related-icon:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.modal-related-loading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6366f1;
}

.modal-related-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.5rem;
    color: #71717a;
    font-size: 0.813rem;
}

/* Hide related section in editor mode */
.modal-content.editor-active .modal-related-section {
    display: none;
}

/* Modal View States */
.modal-view-detail {
    display: block;
}

.modal-view-editor {
    display: none;
}

.editor-hint {
    font-size: 0.75rem;
    color: #71717a;
    line-height: 1.4;
    margin: 0 0 8px 0;
}

/* =========================================
   EDITOR VIEW STYLES
   ========================================= */
.modal-view-editor {
    flex-direction: column;
    width: 100%;
    height: 85vh;
    max-height: 800px;
    background-color: #18181b;
    overflow: hidden;
}

.editor-header {
    height: 60px;
    min-height: 60px;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #18181b;
    flex-shrink: 0;
    gap: 0.5rem;
}

.editor-header .btn-back {
    flex: none;
    width: auto;
}

.editor-header .btn-tool {
    padding: 0.5rem 1rem;
}

.editor-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.editor-actions .btn-download-svg {
    padding: 0.5rem 1rem;
}

/* PNG download group with size selector */
.png-download-group {
    display: flex;
    align-items: center;
    gap: 0;
    height: 36px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 8px;
}

.png-download-group .btn-download-svg {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    height: 100%;
    padding: 0 1rem;
    font-size: 0.8rem;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-right: none;
    color: #e4e4e7;
    font-weight: 500;
}

.png-download-group .btn-download-svg:hover {
    background: #3f3f46;
    color: white;
    transform: none;
    box-shadow: none;
}

.png-size-select {
    padding: 0 0.5rem 0 0.25rem;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 8px 8px 0;
    color: #a1a1aa;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    height: 100%;
    margin-left: 0;
}

.png-size-select:hover {
    background: #3f3f46;
    color: white;
}

.png-size-select:focus {
    color: #6366f1;
}

.editor-footer {
    height: 60px;
    min-height: 60px;
    padding: 0 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: #18181b;
    flex-shrink: 0;
    gap: 1rem;
}

.editor-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
}

.editor-sidebar-wrapper {
    display: flex;
    flex-direction: column;
    width: 380px;
    min-width: 380px;
    max-height: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    flex-shrink: 0;
}

.editor-sidebar-tabs {
    display: flex;
    flex-direction: row;
    background: #0f0f11;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    gap: 4px;
    flex-shrink: 0;
}


/* =========================================
   LIGHT THEME OVERRIDES
   ========================================= */

/* Modal Container & Content */
html.light .modal-content,
html.light .modal-view-editor,
html.light .editor-header,
html.light .editor-footer,
html.light .editor-sidebar-wrapper,
html.light .editor-sidebar-tabs {
    background: #ffffff !important;
    border-color: #e4e4e7 !important;
}

/* Text Colors */
html.light .modal-icon-name,
html.light .modal-related-title,
html.light .editor-hint {
    color: #18181b !important;
}

html.light .modal-icon-subtitle,
html.light .modal-code-hint {
    color: #52525b !important;
}

html.light .modal-close-btn {
    background: rgba(0, 0, 0, 0.05) !important;
    color: #71717a !important;
}

html.light .modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
}

/* Code Block in Details */
html.light .modal-code-container {
    background: #f4f4f5 !important;
    border: 1px solid #e4e4e7 !important;
}

html.light .modal-code-container:hover {
    background: #e4e4e7 !important;
    border-color: #d4d4d8 !important;
}

html.light .modal-code-content {
    color: #18181b !important;
}

/* Actions Bar */
html.light .modal-actions {
    background: #f4f4f5 !important;
    border: 1px solid #e4e4e7 !important;
}

html.light .modal-action-btn {
    color: #52525b !important;
}

html.light .modal-action-btn:hover {
    background: #e4e4e7 !important;
    color: #18181b !important;
}

html.light .modal-action-btn.active {
    background: #6366f1 !important;
    color: #ffffff !important;
}

/* Editor Inputs & Selects */
html.light .btn-edit-icon,
html.light .png-size-select,
html.light .btn-download-svg {
    border-color: #e4e4e7 !important;
    color: #52525b !important;
    background: #ffffff !important;
}

html.light .png-download-group .btn-download-svg {
    background: #f4f4f5 !important;
    color: #18181b !important;
}

html.light .btn-edit-icon:hover,
html.light .png-size-select:hover {
    background: #f4f4f5 !important;
    color: #18181b !important;
}

/* Related Icons Section */
html.light .modal-related-section {
    background: #f8fafc !important;
    border-top-color: #e4e4e7 !important;
}

html.light .modal-related-icon {
    background: #ffffff !important;
    border-color: #e4e4e7 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

html.light .modal-related-icon:hover {
    border-color: #6366f1 !important;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.1) !important;
}

html.light .modal-related-icon i {
    color: #52525b !important;
}

html.light .modal-related-icon:hover i {
    color: #6366f1 !important;
}

/* Editor Sidebar Tabs */
html.light .editor-sidebar-tabs {
    background: #f4f4f5 !important;
    border-bottom: 1px solid #e4e4e7 !important;
}

html.light .sidebar-tab {
    color: #71717a !important;
}

html.light .sidebar-tab:hover {
    background: #e4e4e7 !important;
    color: #18181b !important;
}

html.light .sidebar-tab.active {
    background: #ffffff !important;
    color: #18181b !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}




.editor-sidebar {
    width: 100%;
    min-width: unset;
    background: #18181b;
    border-right: none;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.editor-sidebar::-webkit-scrollbar {
    width: 5px;
}

.editor-sidebar::-webkit-scrollbar-thumb {
    background-color: #3f3f46;
    border-radius: 10px;
}

.editor-panel {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.editor-panel.active {
    display: flex;
}

.editor-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.editor-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fafafa;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.editor-section-title i {
    color: #6366f1;
    font-size: 0.8rem;
}

.tools-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: #a1a1aa;
    font-weight: 500;
}

.tool-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 90px;
}

.tool-row i {
    color: #71717a;
    width: 16px;
    text-align: center;
}

.tool-row input[type="range"] {
    flex: 1;
    height: 5px;
    background: #3f3f46;
    border-radius: 3px;
    accent-color: #6366f1;
    cursor: pointer;
    border: none;
}

/* Input number cho size */
.tool-row input[type="number"],
#tool-size-input {
    width: 60px;
    padding: 6px 8px;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    color: #e4e4e7;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -moz-appearance: textfield;
    appearance: textfield;
}

.tool-row input[type="number"]::-webkit-outer-spin-button,
.tool-row input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tool-row input[type="number"]:focus,
#tool-size-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.tool-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.btn-tool {
    flex: 1;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    border-radius: 8px;
    color: #a1a1aa;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-tool:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

/* Position Controls - Arrow buttons */
.position-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.position-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.btn-arrow {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #27272a;
    border-radius: 10px;
    color: #a1a1aa;
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.btn-arrow:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.15);
    transform: scale(1.05);
}

.btn-arrow:active {
    transform: scale(0.95);
    background: rgba(99, 102, 241, 0.25);
}

.btn-arrow.btn-center {
    background: #3f3f46;
    color: #e4e4e7;
}

.btn-arrow.btn-center:hover {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

.shape-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.btn-shape {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    border-radius: 8px;
    color: #a1a1aa;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 9px;
}

.btn-shape i {
    font-size: 16px;
}

.btn-shape:hover,
.btn-shape.active {
    border-color: #6366f1;
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.bg-color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #27272a;
    border-radius: 8px;
}

.bg-color-picker input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.bg-color-value {
    font-family: monospace;
    font-size: 0.85rem;
    color: #a1a1aa;
}

.bg-color-presets {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.bg-preset {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.bg-preset:hover {
    transform: scale(1.1);
    border-color: #6366f1;
}

.range-value {
    font-size: 0.8rem;
    color: #a1a1aa;
    min-width: 40px;
    text-align: right;
}

.color-swatches-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
    background: #27272a;
    border-radius: 8px;
}

.color-swatch-large {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.color-swatch-large input[type="color"] {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    padding: 0;
    margin: 0;
    border: none;
    cursor: pointer;
}

.swatch-type-label {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    line-height: 1;
    pointer-events: none;
}

.color-info {
    display: flex;
    flex-direction: column;
}

#editor-color-hex {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #fafafa;
    font-size: 1rem;
}

.color-label {
    font-size: 0.7rem;
    color: #71717a;
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-clear-history {
    font-size: 0.7rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 4px 10px;
    border-radius: 99px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-clear-history:hover {
    background: #ef4444;
    color: white;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.history-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.history-swatch:hover {
    transform: scale(1.05);
}

/* Container chứa preview */
.editor-main-preview {
    flex: 1;
    background-color: #18181b;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 350px;
    padding: 20px;
}

/* Wrapper hình vuông bao quanh icon */
.editor-preview-wrapper {
    position: relative;
    /* Hình vuông - lấy kích thước nhỏ hơn giữa chiều rộng và chiều cao */
    width: min(100%, calc(100vh - 200px));
    aspect-ratio: 1 / 1;
    max-width: 500px;
    max-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Background bàn cờ tối màu */
    background-color: #1e1e1e;
    background-image:
        linear-gradient(45deg, #252525 25%, transparent 25%),
        linear-gradient(-45deg, #252525 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #252525 75%),
        linear-gradient(-45deg, transparent 75%, #252525 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 0px;
    overflow: hidden;
    container-type: size;
}

.editor-icon-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70%;
    height: 70%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    transition: all 0.2s ease;
    border-radius: 8px;
}

/* Icon fit 100% với wrapper */
.editor-preview-icon {
    /* Phủ toàn bộ wrapper - IMPORTANT to override home.css */
    position: absolute !important;
    inset: 0 !important;
    z-index: 10;
    cursor: pointer;
    user-select: none;
    /* Center SVG child */
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1;
    background: transparent !important;
    border: none;
    box-shadow: none;
    transform-origin: center center;
    /* Remove font-size that causes height issues */
    font-size: inherit;
}

/* SVG icon sizing for editor preview */
.editor-preview-icon svg {
    /* Use !important to override inline styles from Smart Loader */
    width: 100% !important;
    height: 100% !important;
    /* background-color: red; */
}

/* Fallback cho trình duyệt không hỗ trợ cqmin */
@supports not (font-size: 100cqmin) {
    .editor-preview-icon {
        font-size: 280px;
    }
}

.editor-preview-icon span {
    cursor: pointer;
}

.editor-preview-icon:active {
    cursor: move;
}

.editor-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(39, 39, 42, 0.9);
    z-index: 100;
    border-radius: 8px;
}

.editor-loading.hidden {
    display: none;
}

.editor-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.editor-floating-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20;
}

/* Responsive Modal */
@media (max-width: 768px) {

    /*
      Mobile: fullscreen modal with single scroll container.
      Desktop rules remain unchanged (this block only applies on mobile).
    */
    .icon-detail-modal {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .modal-content {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .modal-grid {
        grid-template-columns: 1fr;
        min-height: unset;
    }

    .modal-icon-preview {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 1.5rem 1rem;
        min-height: 160px;
    }

    .modal-icon-display {
        font-size: 5.5rem;
    }

    .modal-view-detail {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Avoid nested scroll on mobile; let .modal-view-detail handle scrolling */
    .modal-icon-details {
        padding: 1rem;
        overflow: visible;
        max-height: none;
    }

    /* Editor responsive */
    .modal-view-editor {
        height: 100%;
        max-height: none;
    }

    .editor-body {
        flex-direction: column;
    }

    .editor-sidebar-wrapper {
        width: 100%;
        min-width: unset;
        max-height: 40%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .editor-header {
        padding: 0 0.75rem;
        height: 50px;
        min-height: 50px;
        flex-wrap: wrap;
    }

    .editor-footer {
        padding: 0 0.75rem;
        height: 50px;
        min-height: 50px;
        gap: 0.5rem;
    }

    .editor-header .btn-back {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .editor-header .btn-tool {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .editor-actions {
        gap: 4px;
    }

    .editor-actions .btn-download-svg {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .png-size-select {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .editor-sidebar-tabs {
        padding: 4px;
        gap: 2px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .sidebar-tab {
        padding: 8px 10px;
        font-size: 10px;
        gap: 4px;
    }

    .sidebar-tab i {
        font-size: 14px;
    }

    .editor-sidebar {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .editor-main-preview {
        min-height: 250px;
        padding: 10px;
    }

    .editor-preview-wrapper {
        max-width: 300px;
        max-height: 300px;
    }
}

/* Toast Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* Toast notification styling */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.3);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Animation for icon cards */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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


/* =========================================
   LIGHT THEME OVERRIDES (COMPREHENSIVE)
   ========================================= */

/* GLOBAL MODAL CONTAINERS */
/* GLOBAL MODAL CONTAINERS - NEO-BRUTALISM */
html.light .modal-content,
html.light .modal-view-editor,
html.light .editor-body,
html.light .editor-sidebar-wrapper,
html.light .editor-sidebar,
html.light .editor-header,
html.light .editor-footer,
html.light .editor-sidebar-tabs,
html.light .modal-icon-preview {
    background-color: #ffffff !important;
    border-color: #000000 !important;
    color: #000000 !important;
}

html.light .modal-content {
    border: 3px solid #000000 !important;
    box-shadow: 8px 8px 0px 0px #000000 !important;
    border-radius: 12px !important;
}

/* TEXT & ICONS */
html.light .modal-icon-name,
html.light .modal-related-title,
html.light .editor-hint,
html.light .modal-icon-display {
    color: #18181b !important;
}

html.light .modal-icon-subtitle,
html.light .png-size-option {
    color: #52525b !important;
}

html.light .modal-code-hint {
    background-color: #e4e4e7 !important;
    color: #18181b !important;
}

/* PREVIEW AREA SPECIFICS */
/* Ensure the preview area respects light theme unless specifically toggled to dark inside the modal */
html.light .modal-icon-preview:not(.dark-mode) {
    background-color: #ffffff !important;
}

html.light .modal-icon-preview.dark-mode {
    background-color: #27272A !important;
    color: #ffffff !important;
}

html.light .modal-icon-preview.dark-mode .modal-icon-display {
    color: #ffffff !important;
}

/* BUTTONS & CONTROLS */
/* BUTTONS & CONTROLS - NEO-BRUTALISM */
html.light .modal-close-btn {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
    opacity: 1 !important;
}

html.light .modal-close-btn:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    box-shadow: 3px 3px 0px 0px #000000 !important;
    transform: translate(-1px, -1px) !important;
}

html.light .sidebar-tab {
    color: #71717a !important;
    background: transparent !important;
}

html.light .sidebar-tab:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: #18181b !important;
}

html.light .sidebar-tab.active {
    background: #eff6ff !important;
    /* blue-50 */
    color: #3b82f6 !important;
    /* blue-500 */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

/* CODE BLOCKS */
/* CODE BLOCKS - NEO-BRUTALISM */
html.light .modal-code-container {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    border-radius: 8px !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
}

html.light .modal-code-container:hover {
    background: #F5C518 !important;
    box-shadow: 4px 4px 0px 0px #000000 !important;
    transform: translate(-2px, -2px) !important;
}

html.light .modal-code-content {
    color: #0f172a !important;
    /* slate-900 */
}

/* EDITOR INPUTS */
/* EDITOR INPUTS & ACTION BUTTONS - NEO-BRUTALISM */
html.light .btn-edit-icon,
html.light .png-size-select,
html.light .btn-download-svg,
html.light .modal-action-btn {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
}

html.light .btn-edit-icon:hover,
html.light .png-size-select:hover,
html.light .btn-download-svg:hover,
html.light .modal-action-btn:hover {
    background: #F5C518 !important;
    /* Yellow */
    color: #000000 !important;
    box-shadow: 3px 3px 0px 0px #000000 !important;
    transform: translate(-1px, -1px) !important;
}

html.light .modal-action-btn.active {
    background: #6366f1 !important;
    /* Purple */
    color: #ffffff !important;
    box-shadow: 3px 3px 0px 0px #000000 !important;
}

/* RELATED SECTION */
/* RELATED SECTION - NEO-BRUTALISM */
html.light .modal-related-section {
    background: #f8fafc !important;
    border-top: 2px solid #000000 !important;
}

html.light .modal-related-icon {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    border-radius: 8px !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
}

html.light .modal-related-icon:hover {
    background: #F5C518 !important;
    box-shadow: 4px 4px 0px 0px #000000 !important;
    transform: translate(-2px, -2px) !important;
}

html.light .modal-related-icon i {
    color: #000000 !important;
}


/* EDITOR PREVIEW AREA - LIGHT THEME */
html.light .editor-main-preview {
    background-color: #f8fafc !important;
    /* Slightly distinct from sidebar white */
}

/* Make the canvas wrapper lighter but still distinguishable as transparency grid */
html.light .editor-preview-wrapper {
    background-color: #ffffff !important;
    background-image:
        linear-gradient(45deg, #f4f4f5 25%, transparent 25%),
        linear-gradient(-45deg, #f4f4f5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f4f4f5 75%),
        linear-gradient(-45deg, transparent 75%, #f4f4f5 75%) !important;
    border: 1px solid #e4e4e7;
}

/* Loading Overlay */
html.light .editor-loading {
    background: rgba(255, 255, 255, 0.95) !important;
}

html.light .editor-spinner {
    border-color: rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
}

/* EDITOR TOOLBAR BUTTONS - NEO-BRUTALISM */
html.light .btn-tool {
    color: #000000 !important;
    border: 2px solid #000000 !important;
    background: #ffffff !important;
    border-radius: 6px !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
    font-weight: 600 !important;
}

html.light .btn-tool:hover {
    background: #F5C518 !important;
    color: #000000 !important;
    border-color: #000000 !important;
    box-shadow: 4px 4px 0px 0px #000000 !important;
    transform: translate(-2px, -2px) !important;
}

html.light .btn-arrow {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
    border-radius: 6px !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
}

html.light .btn-arrow:hover {
    background: #F5C518 !important;
    color: #000000 !important;
    border-color: #000000 !important;
    box-shadow: 4px 4px 0px 0px #000000 !important;
    transform: translate(-2px, -2px) !important;
}

html.light .btn-arrow.btn-center {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

html.light .btn-arrow.btn-center:hover {
    background: #6366f1 !important;
    color: white !important;
    box-shadow: 4px 4px 0px 0px #000000 !important;
    transform: translate(-2px, -2px) !important;
}

html.light .btn-shape {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
    border-radius: 6px !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
}

html.light .btn-shape:hover {
    background: #F5C518 !important;
    border-color: #000000 !important;
    color: #000000 !important;
    box-shadow: 4px 4px 0px 0px #000000 !important;
    transform: translate(-2px, -2px) !important;
}

html.light .btn-shape.active {
    background: #6366f1 !important;
    border-color: #000000 !important;
    color: #ffffff !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
}

/* INPUTS & PICKERS - NEO-BRUTALISM */
html.light .bg-color-picker,
html.light .color-picker-wrapper {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    border-radius: 6px !important;
}

html.light .tool-row input[type="number"] {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
}

html.light .tool-row i {
    color: #52525b !important;
}

html.light .bg-color-value {
    color: #52525b !important;
}

html.light .bg-preset {
    border-color: #e4e4e7 !important;
}

html.light .color-swatch-large {
    border-color: #e4e4e7 !important;
}

html.light .history-swatch {
    border-color: #e4e4e7 !important;
}

html.light #editor-color-hex {
    color: #18181b !important;
}

html.light .color-label {
    color: #71717a !important;
}

/* ===========================================
   MISSING EDITOR SIDEBAR STYLES (Ported from home.css)
   =========================================== */
.editor-sidebar-tabs {
    display: flex;
    flex-direction: row;
    background: #0f0f11;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    gap: 4px;
}

.sidebar-tab {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #71717a;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
    font-weight: 500;
}

.sidebar-tab i {
    font-size: 18px;
}

.sidebar-tab:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #a1a1aa;
}

.sidebar-tab.active {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
}

.editor-sidebar {
    width: 360px;
    background: #18181b;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.editor-sidebar::-webkit-scrollbar {
    width: 5px;
}

.editor-sidebar::-webkit-scrollbar-thumb {
    background-color: #3f3f46;
    border-radius: 10px;
}

/* Light Theme Overrides for Sidebar Tabs - NEO-BRUTALISM */
html.light .editor-sidebar-tabs {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    border-radius: 8px !important;
}

html.light .sidebar-tab {
    color: #000000 !important;
    font-weight: 600 !important;
    border: 2px solid transparent !important;
    border-radius: 6px !important;
}

html.light .sidebar-tab:hover {
    background: #F5C518 !important;
    color: #000000 !important;
    border-color: #000000 !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
    transform: translate(-1px, -1px) !important;
}

html.light .sidebar-tab.active {
    background: #6366f1 !important;
    color: #ffffff !important;
    border-color: #000000 !important;
    box-shadow: 2px 2px 0px 0px #000000 !important;
}

html.light .editor-sidebar {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    border-radius: 8px !important;
}

html.light .editor-sidebar::-webkit-scrollbar-thumb {
    background-color: #d4d4d8 !important;
}

/* Editor Section Title Light Theme */
html.light .editor-section-title {
    color: #18181b !important;
}

html.light .editor-section-title i {
    color: #6366f1 !important;
}

/* Share Social Button Styles */
.share-social-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: #000000;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.share-social-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-social-btn i {
    font-size: 24px;
    color: #000000;
}

.share-social-btn span {
    font-size: 12px;
    font-weight: 500;
    color: #000000;
}

/* Platform-specific colors for share-social-btn */
.share-social-btn[data-platform="twitter"] {
    background: rgba(29, 161, 242, 0.1);
    border-color: rgba(29, 161, 242, 0.3);
}

.share-social-btn[data-platform="twitter"] i,
.share-social-btn[data-platform="twitter"] span {
    color: #1DA1F2;
}

.share-social-btn[data-platform="twitter"]:hover {
    background: rgba(29, 161, 242, 0.2);
    border-color: rgba(29, 161, 242, 0.5);
}

.share-social-btn[data-platform="facebook"] {
    background: rgba(24, 119, 242, 0.1);
    border-color: rgba(24, 119, 242, 0.3);
}

.share-social-btn[data-platform="facebook"] i,
.share-social-btn[data-platform="facebook"] span {
    color: #1877F2;
}

.share-social-btn[data-platform="facebook"]:hover {
    background: rgba(24, 119, 242, 0.2);
    border-color: rgba(24, 119, 242, 0.5);
}

.share-social-btn[data-platform="linkedin"] {
    background: rgba(0, 119, 181, 0.1);
    border-color: rgba(0, 119, 181, 0.3);
}

.share-social-btn[data-platform="linkedin"] i,
.share-social-btn[data-platform="linkedin"] span {
    color: #0077B5;
}

.share-social-btn[data-platform="linkedin"]:hover {
    background: rgba(0, 119, 181, 0.2);
    border-color: rgba(0, 119, 181, 0.5);
}

.share-social-btn[data-platform="reddit"] {
    background: rgba(255, 69, 0, 0.1);
    border-color: rgba(255, 69, 0, 0.3);
}

.share-social-btn[data-platform="reddit"] i,
.share-social-btn[data-platform="reddit"] span {
    color: #FF4500;
}

.share-social-btn[data-platform="reddit"]:hover {
    background: rgba(255, 69, 0, 0.2);
    border-color: rgba(255, 69, 0, 0.5);
}

/* Copy Link Button Styles */
#copy-link-btn {
    color: #ffffff !important;
}

@media (min-width: 480px) {
    .editor-sidebar {
        width: 100%;
    }
}

/* =========================================
   RESPONSIVE STYLES (Small Screens)
   ========================================= */
@media (max-width: 480px) {
    .icon-detail-modal {
        padding: 1rem;
        align-items: center;
    }

    .modal-content {
        max-height: 95vh;
        /* Tăng chiều cao để chứa đủ nội dung */
        border-radius: 5px;
        display: flex;
        flex-direction: column;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    }

    .modal-grid {
        display: flex;
        flex-direction: column;
        min-height: auto;
        overflow-y: auto;
    }

    /* Icon Preview Area */
    .modal-icon-preview {
        padding: 2rem 1rem;
        min-height: 180px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-top-left-radius: 5px;
        border-top-right-radius: 5px;
    }

    /* Scale down main icon */
    .modal-icon-display {
        font-size: 5rem;
    }

    /* Details Area */
    .modal-icon-details {
        padding: 1rem;
        gap: 0.75rem;
        overflow: visible;
    }

    /* Typography */
    .modal-icon-name {
        font-size: 1.25rem;
        line-height: 1.2;
    }

    /* Actions */
    .modal-actions {
        flex-wrap: wrap;
    }

    .modal-action-btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Code Block */
    .modal-code-container {
        min-height: 60px;
        max-height: 120px;
    }

    .modal-code-scroll {
        padding: 0.75rem;
        padding-top: 2rem;
    }

    .modal-code-content {
        font-size: 0.7rem;
    }

    /* Related Icons Grid */
    .modal-related-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .modal-related-icon {
        height: 80px;
    }

    .modal-related-icon i {
        font-size: 1.5rem !important;
    }

    /* --- EDITOR STYLES ON MOBILE (OPTIMIZED) --- */

    .editor-body {
        flex-direction: column;
        height: 100%;
        /* Đảm bảo fill chiều cao */
        overflow: hidden;
    }

    /* 1. Preview Area - Lên trên cùng */
    .editor-main-preview {
        order: -1;
        /* Đưa lên đầu */
        min-height: 220px;
        height: 35vh;
        /* Chiếm khoảng 35% màn hình */
        padding: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0;
        /* Bo góc xử lý ở wrapper hoặc modal-content */
        flex-shrink: 0;
        /* Không bị co lại */
    }

    .editor-preview-wrapper {
        max-width: 180px;
        max-height: 180px;
        border-radius: 8px;
    }

    /* 2. Sidebar Wrapper - Xuống dưới */
    .editor-sidebar-wrapper {
        order: 1;
        width: 100%;
        min-width: unset;
        max-height: none;
        /* Bỏ giới hạn cũ */
        flex: 1;
        /* Chiếm hết phần còn lại */
        border-right: none;
        display: flex;
        flex-direction: column;
        overflow: visible;
        /* Fix clipping issue */
        overflow-x: hidden;
    }

    /* 3. Sidebar Tabs - Nhỏ gọn, Icon + Text ngang hàng */
    .editor-sidebar-tabs {
        padding: 6px;
        gap: 4px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        overflow-x: auto;
        flex-shrink: 0;
    }

    .sidebar-tab {
        flex: 1;
        flex-direction: row;
        /* Icon cạnh text */
        gap: 10px;
        /* Gap theo yêu cầu */
        padding: 8px 12px;
        justify-content: center;
        min-width: fit-content;
        font-size: 0.8rem;
    }

    .sidebar-tab i {
        font-size: 1rem;
        margin-bottom: 0;
        /* Reset margin cũ nếu có */
    }

    /* 4. Sidebar Content - Compact */
    .editor-sidebar {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        /* Prevent horizontal scroll */
        padding: 0.75rem;
        /* Giảm padding */
        gap: 0.75rem;
        /* Giảm khoảng cách các phần */
        width: 100%;
        box-sizing: border-box;
        /* Ensure padding includes in width */
    }

    /* Compact Sidebar Elements */
    .editor-section {
        gap: 6px;
        /* Giảm gap trong section */
        width: 100%;
    }

    .editor-section-title {
        font-size: 0.75rem;
        /* Bé hơn */
        margin-bottom: 2px;
    }

    .tool-row {
        gap: 8px;
        font-size: 0.75rem;
        /* Bé hơn */
        width: 100%;
        flex-wrap: wrap;
        /* Allow wrapping on very small screens */
    }

    .tool-row label {
        min-width: 60px;
        gap: 4px;
    }

    /* Fixed Layout for Tool Actions (Flip Buttons) */
    .tool-actions-row {
        display: flex;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }

    .tool-actions-row .btn-tool {
        flex: 1;
        /* Stretch buttons */
        justify-content: center;
        width: auto;
    }

    /* Fixed Layout for Position Row (Movement Buttons) */
    .position-row {
        display: flex;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
        /* Spread buttons */
    }

    .position-row .btn-tool,
    .position-row .btn-arrow {
        flex: 1;
        /* Stretch buttons */
        justify-content: center;
    }

    /* Ensure scrollbar doesn't eat content */
    .editor-sidebar {
        padding-right: 2px;
        /* Tiny extra buffer */
        padding: 0.5rem;
        /* Reduce padding to give more width */
    }

    .btn-tool,
    .btn-arrow,
    .btn-shape {
        padding: 4px 6px;
        font-size: 0.7rem;
    }

    .btn-arrow {
        width: 32px;
        height: 32px;
    }

    .tool-row input[type="number"],
    #tool-size-input {
        width: 45px;
        padding: 4px;
        font-size: 0.75rem;
    }

    .bg-color-picker,
    .color-picker-wrapper {
        padding: 6px;
        gap: 8px;
    }

    /* Footer - Single Row Optimized Layout */
    .editor-footer {
        flex-shrink: 0;
        padding: 0.5rem;
        height: auto;
        min-height: unset;
        display: grid;
        grid-template-columns: auto auto 1fr;
        /* Let buttons size to content, PNG takes rest */
        gap: 8px;
        order: 2;
        background: #18181b;
    }

    /* Common Button Style overrides for compact 1-row */
    .editor-footer #editor-copy-svg,
    .editor-footer #editor-download-svg,
    .png-download-group {
        height: 38px;
        width: 100%;
        margin: 0 !important;
        font-size: 0.75rem;
        padding: 0 8px;
        /* Standard padding */
    }

    /* Child 1: Copy SVG */
    .editor-footer #editor-copy-svg {
        grid-column: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border-radius: 8px;
        background: #27272a;
        border: 1px solid rgba(255, 255, 255, 0.1);
        white-space: nowrap;
    }

    /* Child 2: SVG Download */
    .editor-footer #editor-download-svg {
        grid-column: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border-radius: 8px;
        white-space: nowrap;
    }

    /* Child 3: PNG Group */
    .png-download-group {
        grid-column: auto;
        display: flex;
        align-items: center;
        position: relative;
        padding: 0;
        border-radius: 8px;
        overflow: hidden;
        min-width: 0;
        /* Important for flex/grid shrinking */
    }

    .png-download-group .btn-download-svg {
        flex: 0 0 auto;
        width: auto;
        height: 100%;
        padding: 0 8px;
        font-size: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px 0 0 8px;
        gap: 4px;
        white-space: nowrap;
    }

    .png-download-group .btn-download-svg i {
        font-size: 12px;
    }

    .png-size-select {
        flex: 1;
        min-width: 0;
        width: 100%;
        height: 100%;
        font-size: 0.75rem;
        border-radius: 0 8px 8px 0;
        text-align: center;
        padding: 0 0 0 4px;
        /* Slight left padding */
        text-indent: 0;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        appearance: none;
        background-color: transparent;
        color: #fff;
        /* Ensure contrast */
    }

    /* Force Dropdown Upwards */
    .png-size-dropdown {
        bottom: 115%;
        top: auto;
        left: auto;
        right: 0;
        min-width: 120px;
        width: auto;
        margin-bottom: 0;
        z-index: 9999;
    }

    .editor-actions {
        display: contents;
    }
}