/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    min-height: 100vh;
    color: #333;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.header p {
    color: rgba(0, 0, 0, 0.6);
    font-size: 1.1rem;
}

/* ===== CARD HEADER (inside card) ===== */
.card-header {
    text-align: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.card-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.card-header p {
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.main-content-single {
    grid-template-columns: 1fr;
    max-width: 700px;
    margin: 0 auto;
}

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

/* ===== ERROR MESSAGE ===== */
.error-message {
    text-align: center;
    padding: 60px 20px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 16px;
    margin-top: 50px;
}

.error-message h1 {
    color: #e94560;
    margin-bottom: 15px;
}

.error-message p {
    color: rgba(0, 0, 0, 0.6);
    margin-bottom: 10px;
}

.error-message code {
    background: rgba(0, 0, 0, 0.08);
    padding: 5px 12px;
    border-radius: 5px;
    font-family: monospace;
}

.error-message .btn {
    margin-top: 25px;
}

.error-box {
    text-align: center;
    padding: 30px;
}

.error-box p {
    margin-bottom: 20px;
    color: #e94560;
}

.loading-placeholder {
    text-align: center;
    padding: 40px;
    color: rgba(0, 0, 0, 0.4);
}

/* ===== SEARCH SECTION ===== */
.search-section {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: #fff;
    color: #333;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #e94560;
    background: #fff;
}

.search-box input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
    background: #fff;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.btn-secondary:hover {
    background: #f5f5f5;
    border-color: rgba(0, 0, 0, 0.25);
}

.btn-success {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: #fff;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 184, 148, 0.4);
}

.btn-large {
    padding: 18px 40px;
    font-size: 1.1rem;
    width: 100%;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
}

.action-buttons .btn {
    text-align: center;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== OFFERTE LIST ===== */
.offerte-list {
    max-height: 500px;
    overflow-y: auto;
}

.offerte-list::-webkit-scrollbar {
    width: 8px;
}

.offerte-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

.offerte-list::-webkit-scrollbar-thumb {
    background: rgba(233, 69, 96, 0.4);
    border-radius: 4px;
}

.placeholder-text {
    text-align: center;
    color: rgba(0, 0, 0, 0.4);
    padding: 40px;
}

.placeholder-text.error {
    color: #e94560;
}

/* Ricerca full width */
.search-section-full {
    max-width: 900px;
    margin: 0 auto;
}

/* Offerta come link */
.offerta-link {
    text-decoration: none;
    display: block;
}

.offerta-link:hover {
    transform: translateX(5px);
}

.offerta-item {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.offerta-item:hover {
    background: #fafafa;
    border-color: rgba(233, 69, 96, 0.3);
}

.offerta-item.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.05);
}

.offerta-item h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: #333;
}

.offerta-item .meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.5);
}

.offerta-item .price {
    color: #00a896;
    font-weight: 700;
}

/* ===== PREVIEW SECTION ===== */
.preview-section {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.preview-section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.offerta-details {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.offerta-details .detail-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.offerta-details .detail-label {
    width: 140px;
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
}

.offerta-details .detail-value {
    flex: 1;
    color: #333;
}

.offerta-details .detail-value.highlight {
    color: #00a896;
    font-weight: 700;
    font-size: 1.2rem;
}

.offerta-details .detail-value .logo-to {
    max-height: 40px;
    max-width: 150px;
    object-fit: contain;
    vertical-align: middle;
}

.offerta-details .detail-row-descrizione {
    flex-direction: column;
    align-items: flex-start;
}

.offerta-details .detail-textarea {
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    resize: vertical;
    min-height: 70px;
}

.offerta-details .detail-textarea:focus {
    outline: none;
    border-color: #00cec9;
    background: #fff;
}

.offerta-details .detail-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
}

.offerta-details .detail-input:focus {
    outline: none;
    border-color: #00cec9;
    background: #fff;
}

.offerta-details .detail-image {
    margin-top: 15px;
    border-radius: 10px;
    overflow: hidden;
}

.offerta-details .detail-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.offerta-details .detail-image .image-url {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    word-break: break-all;
    font-family: monospace;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #fff;
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    font-size: 1.4rem;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(0, 0, 0, 0.4);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #e94560;
}

.modal-body {
    padding: 25px;
    max-height: calc(90vh - 160px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
}

.modal-footer .btn {
    font-size: 0.85rem;
    padding: 10px 18px;
}

/* ===== LAYOUT OPTIONS ===== */
.layout-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .layout-options {
        grid-template-columns: 1fr;
    }
}

.layout-option {
    background: #f8f9fa;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
}

.layout-option:hover {
    background: #f0f2f5;
    border-color: rgba(233, 69, 96, 0.3);
}

.layout-option.selected {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.05);
}

.layout-option h3 {
    margin-top: 15px;
    font-size: 1.1rem;
    color: #333;
}

.layout-option p {
    color: rgba(0, 0, 0, 0.6);
    font-size: 0.9rem;
    margin-top: 5px;
}

.layout-option .layout-desc {
    display: block;
    font-size: 0.8rem;
    color: rgba(0, 0, 0, 0.4);
    margin-top: 8px;
}

.layout-option .recommended {
    display: inline-block;
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 10px;
    text-transform: uppercase;
}

/* ===== LAYOUT PREVIEWS ===== */
.layout-preview {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    padding: 10px;
    font-size: 0.6rem;
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Layout A Preview */
.layout-preview-a {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8), rgba(118, 75, 162, 0.8)), url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect fill="%23667eea" width="100" height="100"/></svg>');
}

.layout-preview-a .lp-logo {
    font-size: 0.5rem;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    margin-bottom: 8px;
}

.layout-preview-a .lp-line {
    width: 60%;
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    margin: 5px 0;
}

.layout-preview-a .lp-title {
    font-weight: 700;
    font-size: 0.7rem;
}

.layout-preview-a .lp-desc {
    font-size: 0.5rem;
    opacity: 0.8;
    margin: 5px 0;
}

.layout-preview-a .lp-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 5px;
    margin: 8px 0;
    text-align: center;
}

.layout-preview-a .lp-link {
    font-size: 0.45rem;
    opacity: 0.6;
}

/* Layout B Preview */
.layout-preview-b {
    justify-content: space-between;
}

.layout-preview-b .lp-logo-small {
    font-size: 0.45rem;
    padding: 2px 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    align-self: flex-start;
}

.layout-preview-b .lp-card {
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
    text-align: left;
}

.layout-preview-b .lp-title {
    font-weight: 700;
    font-size: 0.6rem;
    margin-bottom: 3px;
}

.layout-preview-b .lp-desc {
    font-size: 0.45rem;
    opacity: 0.7;
}

.layout-preview-b .lp-period {
    font-size: 0.45rem;
    margin-top: 5px;
}

.layout-preview-b .lp-price-box {
    display: inline-block;
    background: #e94560;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 700;
    margin-top: 5px;
}

.layout-preview-b .lp-link {
    font-size: 0.4rem;
    opacity: 0.6;
    margin-top: 5px;
}

/* Layout C Preview */
.layout-preview-c {
    padding: 0;
}

.layout-preview-c .lp-image-area {
    flex: 1;
}

.layout-preview-c .lp-gradient {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 10px;
    text-align: left;
}

.layout-preview-c .lp-title {
    font-weight: 700;
    font-size: 0.65rem;
}

.layout-preview-c .lp-desc {
    font-size: 0.45rem;
    opacity: 0.8;
    margin-top: 2px;
}

.layout-preview-c .lp-bottom {
    display: flex;
    justify-content: space-between;
    font-size: 0.45rem;
    margin-top: 5px;
}

.layout-preview-c .lp-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.4rem;
    opacity: 0.6;
    margin-top: 5px;
}

/* ===== CANVAS CONTAINER ===== */
.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f2f5;
    border-radius: 12px;
    padding: 20px;
}

#instagramCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 20px;
    color: rgba(0, 0, 0, 0.6);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .search-box {
        flex-direction: column;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}
