/* Global Style Settings Dialog */
.style-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.style-dialog.active {
    display: flex;
    opacity: 1;
}

.style-dialog-content {
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    width: 90vw;
    height: 90vh;
    position: relative;
    animation: slideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Dialog Header */
.style-dialog-header {
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    position: relative;
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Theme Toggle Button */
.style-theme-toggle {
    position: absolute;
    top: 50%;
    right: 62px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.style-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.style-theme-toggle svg {
    width: 20px;
    height: 20px;
}

.style-close {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.style-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) rotate(90deg);
}

.style-title {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    text-align: left;
    color: #fff;
    letter-spacing: 0.5px;
}

/* Tabs */
.style-tabs {
    display: flex;
    gap: 10px;
    padding: 0 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    scrollbar-width: thin;
    flex-shrink: 0;
}

.style-tabs .tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.style-tabs .tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.style-tabs .tab-btn.active {
    color: #814ac8;
    border-bottom-color: #814ac8;
}

/* Scrollable Content Area */
.style-dialog-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    scrollbar-width: thin;
    scrollbar-color: rgba(129, 74, 200, 0.5) rgba(255, 255, 255, 0.1);
}

.style-dialog-body::-webkit-scrollbar {
    width: 6px;
}

.style-dialog-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.style-dialog-body::-webkit-scrollbar-thumb {
    background: rgba(129, 74, 200, 0.5);
    border-radius: 0;
}

.style-dialog-body::-webkit-scrollbar-thumb:hover {
    background: rgba(129, 74, 200, 0.8);
}

/* Form */
.style-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-section-title {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: none;
    letter-spacing: 0.5px;
}

/* Form Grid - 4 colonne responsive */
.form-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
}

.form-row.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.form-row.cols-1 {
    grid-template-columns: 1fr;
}

/* Responsive breakpoints */
@media (max-width: 1200px) {
    .form-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 25px; /* Spazio tra sezioni */
}

.form-row .form-group {
    margin-bottom: 0; /* Dentro form-row il margin è gestito dal gap */
}

.form-group.full-width {
    grid-column: 1 / -1; /* Occupa tutta la larghezza */
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group textarea,
.form-group .form-select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
    border-radius: 0;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="url"]:focus,
.form-group textarea:focus,
.form-group .form-select:focus {
    outline: none;
    border-color: #814ac8;
    background: rgba(255, 255, 255, 0.08);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.color-picker-input {
    width: 50px;
    max-width: 50px;
    min-width: 50px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    cursor: pointer;
    background: transparent;
    padding: 0;
    flex-shrink: 0;
}

.color-picker-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-input::-webkit-color-swatch {
    border: none;
    border-radius: 0;
}

.color-text-input {
    flex: 1;
    font-family: monospace;
}

/* Checkbox */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #814ac8;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0 5px 0 0;
    vertical-align: middle;
}

.checkbox-label span {
    text-transform: none;
    line-height: 16px;
}

/* Range Input */
input[type="range"] {
    width: calc(100% - 60px);
    accent-color: #814ac8;
}

input[type="range"] + span {
    display: inline-block;
    width: 50px;
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    margin-left: 10px;
}

/* Dialog Footer */
.style-dialog-footer {
    padding: 20px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    background: #000;
    min-height: 80px; /* Assicura visibilità minima */
}

/* Action Buttons */
.style-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}

.btn-style-save,
.btn-style-reset,
.btn-style-preview {
    padding: 8px 16px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border-radius: 0;
    white-space: nowrap;
}

.btn-style-save {
    background: #814ac8;
    color: #fff;
}

.btn-style-save:hover {
    background: #9b66d6;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(129, 74, 200, 0.3);
}

.btn-style-reset {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-style-reset:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.btn-style-preview {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(129, 74, 200, 0.5);
}

.btn-style-preview:hover {
    background: rgba(129, 74, 200, 0.1);
    color: #814ac8;
    border-color: #814ac8;
}

/* Messages */
.style-error,
.style-success {
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 0;
    font-size: 14px;
    text-align: left;
}

.style-error {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #ff6b6b;
}

.style-success {
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid rgba(0, 255, 0, 0.3);
    color: #51cf66;
}

/* Responsive */
@media (max-width: 768px) {
    .style-dialog-content {
        width: 95vw;
        height: 95vh;
    }

    .style-dialog-header {
        padding: 15px 20px;
    }

    .style-title {
        font-size: 14px;
    }

    .style-close {
        top: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 28px;
    }

    .style-tabs {
        gap: 5px;
        padding: 0 20px;
    }

    .style-tabs .tab-btn {
        padding: 10px 12px;
        font-size: 12px;
    }

    .style-dialog-body {
        padding: 20px;
    }

    .style-dialog-footer {
        padding: 15px 20px;
    }

    .style-actions {
        flex-direction: column;
    }

    .btn-style-save,
    .btn-style-reset,
    .btn-style-preview {
        width: 100%;
    }

    .color-picker-input {
        width: 50px;
        max-width: 50px;
        min-width: 50px;
        height: 40px;
    }

    .style-theme-toggle {
        right: 57px;
    }

    .style-close {
        top: 50%;
        transform: translateY(-50%);
    }

    .style-close:hover {
        transform: translateY(-50%) rotate(90deg);
    }
}

/* ============================================ */
/* LIGHT MODE - Solo per Style Dialog          */
/* ============================================ */

.style-dialog.light-mode .style-dialog-content {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
}

.style-dialog.light-mode .style-dialog-header,
.style-dialog.light-mode .style-tabs,
.style-dialog.light-mode .style-dialog-footer {
    border-color: rgba(0, 0, 0, 0.1);
}

.style-dialog.light-mode .style-dialog-footer {
    background: #fff;
}

.style-dialog.light-mode .style-title {
    color: #000;
}

.style-dialog.light-mode .style-theme-toggle,
.style-dialog.light-mode .style-close {
    color: #000;
}

.style-dialog.light-mode .style-theme-toggle:hover,
.style-dialog.light-mode .style-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Light mode: hide sun, show moon */
.style-dialog.light-mode .sun-icon {
    display: none;
}

.style-dialog.light-mode .moon-icon {
    display: block !important;
}

/* Tabs */
.style-dialog.light-mode .style-tabs .tab-btn {
    color: rgba(0, 0, 0, 0.5);
}

.style-dialog.light-mode .style-tabs .tab-btn:hover {
    color: rgba(0, 0, 0, 0.8);
}

.style-dialog.light-mode .style-tabs .tab-btn.active {
    color: #814ac8;
    border-bottom-color: #814ac8;
}

/* Tab section titles */
.style-dialog.light-mode .tab-section-title {
    color: #000;
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Form elements */
.style-dialog.light-mode .form-group label {
    color: rgba(0, 0, 0, 0.8);
}

.style-dialog.light-mode .form-group small {
    color: rgba(0, 0, 0, 0.5);
}

.style-dialog.light-mode .form-group input[type="text"],
.style-dialog.light-mode .form-group input[type="number"],
.style-dialog.light-mode .form-group input[type="url"],
.style-dialog.light-mode .form-group textarea,
.style-dialog.light-mode .form-group .form-select {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #000;
}

.style-dialog.light-mode .form-group input[type="text"]:focus,
.style-dialog.light-mode .form-group input[type="number"]:focus,
.style-dialog.light-mode .form-group input[type="url"]:focus,
.style-dialog.light-mode .form-group textarea:focus,
.style-dialog.light-mode .form-group .form-select:focus {
    border-color: #814ac8;
    background: rgba(0, 0, 0, 0.05);
}

/* Color picker */
.style-dialog.light-mode .color-picker-input {
    border-color: rgba(0, 0, 0, 0.2);
}

.style-dialog.light-mode .color-text-input {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #000;
}

/* Checkbox */
.style-dialog.light-mode .checkbox-label {
    color: rgba(0, 0, 0, 0.8);
}

/* Range input */
.style-dialog.light-mode input[type="range"] + span {
    color: rgba(0, 0, 0, 0.8);
}

/* Scrollbar */
.style-dialog.light-mode .style-dialog-body {
    scrollbar-color: rgba(129, 74, 200, 0.5) rgba(0, 0, 0, 0.1);
}

.style-dialog.light-mode .style-dialog-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.style-dialog.light-mode .style-dialog-body::-webkit-scrollbar-thumb {
    background: rgba(129, 74, 200, 0.5);
}

.style-dialog.light-mode .style-dialog-body::-webkit-scrollbar-thumb:hover {
    background: rgba(129, 74, 200, 0.8);
}

/* Buttons */
.style-dialog.light-mode .btn-style-save {
    background: #814ac8;
    color: #fff;
}

.style-dialog.light-mode .btn-style-save:hover {
    background: #9b66d6;
}

.style-dialog.light-mode .btn-style-reset {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.8);
    border-color: rgba(0, 0, 0, 0.2);
}

.style-dialog.light-mode .btn-style-reset:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
}

.style-dialog.light-mode .btn-style-preview {
    background: rgba(129, 74, 200, 0.05);
    color: #814ac8;
    border-color: rgba(129, 74, 200, 0.3);
}

.style-dialog.light-mode .btn-style-preview:hover {
    background: rgba(129, 74, 200, 0.1);
    border-color: #814ac8;
}

/* Messages */
.style-dialog.light-mode .style-error {
    background: rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 0, 0, 0.3);
    color: #d32f2f;
}

.style-dialog.light-mode .style-success {
    background: rgba(0, 200, 0, 0.1);
    border-color: rgba(0, 200, 0, 0.3);
    color: #2e7d32;
}

/* Export Theme Button */
.btn-export-theme {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #0e639c;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-export-theme:hover {
    background: #1177bb;
}

.btn-export-theme svg {
    flex-shrink: 0;
}

/* Template Cards Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    padding: 10px 0;
}

.template-card {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 500;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
}

.template-card:hover {
    border-color: #814ac8;
}

.template-image {
    width: 100%;
    height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #0d0d0d;
    text-align: center;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

.template-image::-webkit-scrollbar {
    width: 6px;
}

.template-image::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.template-image::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.template-image::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.template-image img {
    width: 95%;
    height: auto;
    object-fit: contain;
}

.template-info {
    padding: 15px;
    text-align: center;
}

.template-name {
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 12px 0;
}

.template-apply-btn {
    width: 100%;
    padding: 8px 16px;
    background: #814ac8;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.template-apply-btn:hover {
    background: #9d5fe0;
}

.template-apply-btn:active {
    transform: scale(0.98);
}

.template-message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

.template-message.success {
    background: rgba(0, 200, 0, 0.1);
    border: 1px solid rgba(0, 200, 0, 0.3);
    color: #4caf50;
}

.template-message.error {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #f44336;
}

.template-message.loading {
    background: rgba(129, 74, 200, 0.1);
    border: 1px solid rgba(129, 74, 200, 0.3);
    color: #814ac8;
}

/* Responsive: 4 cards per row on tablets */
@media (max-width: 1200px) {
    .templates-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Responsive: 3 cards per row on small tablets */
@media (max-width: 900px) {
    .templates-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Responsive: 2 cards per row on mobile */
@media (max-width: 600px) {
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .template-image {
        height: 120px;
    }

    .template-name {
        font-size: 14px;
    }

    .template-apply-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}
