/**
 * GB Preventivi - Frontend Styles
 */

/* ========================================
   Product Preventivo Section
======================================== */
.gbp-product-preventivo-section {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
}

.gbp-product-data {
    margin-bottom: 15px;
}

.gbp-product-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.gbp-product-fields .gbp-field {
    padding: 8px 0;
}

.gbp-product-fields .gbp-field strong {
    color: #333;
    font-weight: 600;
    margin-right: 5px;
}

.gbp-product-fields .gbp-field span {
    color: #666;
}

.gbp-product-specifiche {
    margin-top: 20px;
}

.gbp-product-specifiche h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.gbp-specifiche-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.gbp-specifiche-table thead {
    background: #333;
    color: #fff;
}

.gbp-specifiche-table th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.gbp-specifiche-table td {
    padding: 10px;
    border-bottom: 1px solid #e5e5e5;
    color: #666;
    font-size: 14px;
}

.gbp-specifiche-table tbody tr:hover {
    background: #f5f5f5;
}

.gbp-button-wrapper {
    margin-top: 15px;
}

/* ========================================
   Button
======================================== */
.gbp-open-modal-btn {
    margin: 10px 0;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: #0071a1;
    color: #fff;
    border: none;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.gbp-open-modal-btn:hover {
    background: #005177;
    color: #fff;
}

/* ========================================
   Modal Overlay
======================================== */
.gbp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.gbp-modal-overlay.gbp-hidden {
    display: none;
}

/* ========================================
   Modal Container
======================================== */
.gbp-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    margin: auto;
}
.gbp-modal h2 {
    color: #333;
}

.gbp-form-col input[type="date"],
.gbp-form-col input[type="email"],
.gbp-form-col input[type="number"],
.gbp-form-col input[type="password"],
.gbp-form-col input[type="tel"],
.gbp-form-col input[type="text"],
.gbp-form-col input[type="time"],
.gbp-form-col select,
.gbp-form-col textarea,
.gbp-form-section input[type="date"],
.gbp-form-section input[type="email"],
.gbp-form-section input[type="number"],
.gbp-form-section input[type="password"],
.gbp-form-section input[type="tel"],
.gbp-form-section input[type="text"],
.gbp-form-section input[type="time"],
.gbp-form-section select,
.gbp-form-section textarea {
    color: #333;
}


/* ========================================
   Modal Header
======================================== */
.gbp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.gbp-modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.gbp-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.gbp-modal-close:hover {
    background: #f0f0f0;
}

.gbp-modal-close .dashicons {
    width: 24px;
    height: 24px;
    font-size: 24px;
    color: #666;
}

/* ========================================
   Modal Body
======================================== */
.gbp-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

/* ========================================
   Modal Footer
======================================== */
.gbp-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.gbp-modal-footer .button {
    margin: 0;
}

.gbp-modal-footer .gbp-preview-btn {
    background-color: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.gbp-modal-footer .gbp-preview-btn:hover {
    background-color: #005a87;
    border-color: #005a87;
}

.gbp-modal-footer .gbp-preview-btn.gbp-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.gbp-modal-footer .gbp-preview-btn.gbp-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gbp-spin 0.6s linear infinite;
}

@keyframes gbp-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ========================================
   Form Sections
======================================== */
.gbp-form-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.gbp-form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.gbp-form-section h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.gbp-form-section .description {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
}

/* ========================================
   Form Rows & Columns
======================================== */
.gbp-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.gbp-form-row:last-child {
    margin-bottom: 0;
}

.gbp-form-col {
    flex: 1;
}

.gbp-form-col.gbp-col-half {
    flex: 0 0 calc(50% - 7.5px);
}

.gbp-form-col label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.gbp-form-col .required {
    color: #d63638;
}

.gbp-form-col input[type="text"],
.gbp-form-col input[type="number"],
.gbp-form-col textarea,
.gbp-form-section textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

.gbp-form-col input[type="text"]:focus,
.gbp-form-col input[type="number"]:focus,
.gbp-form-col textarea:focus,
.gbp-form-section textarea:focus {
    outline: none;
    border-color: #2271b1;
}

.gbp-form-col .description {
    margin-top: 5px;
    font-size: 13px;
    color: #666;
}

/* Radio Group */
.gbp-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 8px;
}

.gbp-radio-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
    margin: 0;
    cursor: pointer;
}

.gbp-radio-group input[type="radio"] {
    margin-right: 6px;
    cursor: pointer;
}

/* Utility Classes */
.gbp-hidden {
    display: none !important;
}

/* ========================================
   Frontend Repeater
======================================== */
.gbp-frontend-repeater {
    margin-bottom: 15px;
}

.gbp-repeater-item {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.gbp-repeater-fields {
    flex: 1;
    display: flex;
    gap: 10px;
}

.gbp-repeater-fields input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.gbp-spec-label {
    flex: 0 0 35%;
}

.gbp-spec-value {
    flex: 1;
}

.gbp-permuta-desc {
    flex: 1;
}

.gbp-permuta-valore {
    flex: 0 0 150px;
}

.gbp-remove-item {
    background: #d63638;
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.gbp-remove-item:hover {
    background: #b02a2f;
}

.gbp-remove-item .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
}

/* ========================================
   Riepilogo Section
======================================== */
.gbp-riepilogo-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 4px;
}

.gbp-riepilogo-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.gbp-riepilogo-table td {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.gbp-riepilogo-table tr:last-child td {
    border-bottom: none;
}

.gbp-riepilogo-table .gbp-amount {
    text-align: right;
    font-weight: 600;
    color: #333;
    width: 150px;
}

.gbp-riepilogo-table .gbp-row-strong td {
    font-weight: 700;
    font-size: 16px;
    color: #000;
}

.gbp-riepilogo-table hr {
    border: none;
    border-top: 2px solid #ddd;
    margin: 5px 0;
}

/* ========================================
   Loading State
======================================== */
.gbp-submit-btn.gbp-loading {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.gbp-submit-btn.gbp-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: gbp-spin 0.6s linear infinite;
}

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

/* ========================================
   Success Message
======================================== */
.gbp-success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
    display: none;
}

.gbp-success-message.gbp-show {
    display: block;
}

.gbp-success-message a {
    color: #0c3d1a;
    font-weight: 600;
    text-decoration: underline;
}

/* ========================================
   Error Message
======================================== */
.gbp-error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
    display: none;
}

.gbp-error-message.gbp-show {
    display: block;
}

/* ========================================
   Responsive
======================================== */
@media screen and (max-width: 768px) {
    .gbp-product-preventivo-section {
        padding: 15px;
    }

    .gbp-product-fields {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .gbp-specifiche-table {
        font-size: 13px;
    }

    .gbp-specifiche-table th,
    .gbp-specifiche-table td {
        padding: 8px 5px;
    }

    .gbp-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .gbp-modal-header,
    .gbp-modal-body,
    .gbp-modal-footer {
        padding: 20px;
    }

    .gbp-modal-header h2 {
        font-size: 20px;
    }

    .gbp-form-row {
        flex-direction: column;
        gap: 0;
    }

    .gbp-form-col.gbp-col-half {
        flex: 1;
    }

    .gbp-repeater-fields {
        flex-direction: column;
        gap: 8px;
    }

    .gbp-spec-label,
    .gbp-spec-value,
    .gbp-permuta-desc,
    .gbp-permuta-valore {
        flex: 1;
        width: 100%;
    }

    .gbp-riepilogo-table .gbp-amount {
        width: auto;
    }

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

    .gbp-modal-footer .button {
        width: 100%;
    }
}

@media screen and (max-width: 480px) {
    .gbp-product-preventivo-section {
        padding: 10px;
    }

    .gbp-specifiche-table {
        font-size: 12px;
    }

    .gbp-specifiche-table thead {
        display: none;
    }

    .gbp-specifiche-table td {
        display: block;
        width: 100%;
        text-align: left;
        padding: 5px 10px;
    }

    .gbp-specifiche-table tbody tr {
        display: block;
        margin-bottom: 10px;
        border: 1px solid #e5e5e5;
        border-radius: 4px;
    }

    .gbp-specifiche-table td:first-child {
        font-weight: 600;
        background: #f5f5f5;
        border-bottom: 1px solid #e5e5e5;
    }

    .gbp-modal-overlay {
        padding: 0;
    }

    .gbp-repeater-item {
        flex-direction: column;
        align-items: stretch;
    }

    .gbp-remove-item {
        width: 100%;
        padding: 10px;
    }
}

/* ========================================
   Dashboard Shortcode [tabella_miei_preventivi]
======================================== */

/* Badge stati */
.gbp-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    line-height: 1.6;
}

.gbp-status-aperto     { background: #e8f4fd; color: #0073aa; }
.gbp-status-vinta      { background: #e6f9ed; color: #00a32a; }
.gbp-status-persa      { background: #fce8e8; color: #d63638; }
.gbp-status-acquistato { background: #f3e8ff; color: #8a2be2; }

/* Select stato nel shortcode */
.gbp-status-select {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #c3c4c7;
    cursor: pointer;
    transition: border-color 0.2s;
    background: #fff;
}

.gbp-status-select:focus { border-color: #2271b1; outline: none; }

.gbp-status-feedback { font-size: 11px; margin-left: 4px; }
.gbp-status-saving   { color: #999; }
.gbp-status-ok       { color: #00a32a; font-weight: 700; }
.gbp-status-err      { color: #d63638; font-weight: 700; }

/* Form filtri */
.gbp-filter-form {
    background: #fff;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.gbp-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.gbp-filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 180px;
}

.gbp-filter-field label {
    line-height: 1.5;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gbp-filter-field select,
.gbp-filter-field input[type="text"] {
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #1d2327;
    transition: border-color 0.2s;
}

.gbp-filter-field select:focus,
.gbp-filter-field input[type="text"]:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(34,113,177,.12);
}

.gbp-filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-bottom: 1px;
    flex-shrink: 0;
}

/* Bottoni generici */
.gbp-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.gbp-btn .dashicons {
    font-size: 15px;
    width: 15px;
    height: 15px;
}

.gbp-btn-primary {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}
.gbp-btn-primary:hover { background: #135e96; color: #fff; }

.gbp-btn-secondary {
    background: #f0f0f0;
    color: #555;
    border-color: #c3c4c7;
}
.gbp-btn-secondary:hover { background: #e0e0e0; color: #333; }

/* Tabella dashboard */
.gbp-dashboard-wrapper {
    margin: 0;
    overflow-x: auto;
}

.gbp-preventivi-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
    overflow: hidden;
}

.gbp-preventivi-table thead {
    background: #f9fafb;
}

.gbp-preventivi-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-bottom: 2px solid #e0e4e8;
    white-space: nowrap;
}

.gbp-preventivi-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
    font-size: 14px;
    color: #1d2327;
}

.gbp-preventivi-table tbody tr:hover td {
    background: #f9fafb;
}

.gbp-preventivi-table tbody tr:last-child td {
    border-bottom: none;
}

.gbp-col-numero  { width: 90px; font-weight: 700; color: #2271b1; }
.gbp-col-data    { width: 110px; white-space: nowrap; color: #6b7280; }
.gbp-col-cliente { min-width: 180px; }
.gbp-col-prodotto { min-width: 200px; }
.gbp-col-totale  { width: 130px; text-align: right; font-weight: 700; }
.gbp-col-stato   { width: 130px; }
.gbp-col-azioni  { width: 140px; text-align: center; }

/* Pulsante scarica */
.gbp-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #f0f7ff;
    color: #2271b1;
    text-decoration: none;
    border-radius: 5px;
    border: 1px solid #c5d9f0;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.gbp-download-btn:hover {
    background: #2271b1;
    color: #fff;
}

.gbp-download-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

/* Messaggi */
.gbp-message {
    padding: 15px 20px;
    border-radius: 7px;
    margin: 20px 0;
    font-size: 14px;
}

.gbp-message.gbp-error {
    background: #fce8e8;
    border: 1px solid #f5c6cb;
    color: #b91c1c;
}

.gbp-message.gbp-info {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    color: #0073aa;
}

/* Paginazione */
.gbp-pagination {
    margin: 24px 0;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.gbp-pagination a,
.gbp-pagination span {
    display: inline-block;
    padding: 7px 12px;
    border: 1px solid #e0e4e8;
    background: #fff;
    text-decoration: none;
    color: #1d2327;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}

.gbp-pagination a:hover {
    background: #f0f7ff;
    border-color: #2271b1;
    color: #2271b1;
}

.gbp-pagination .current {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* Responsive shortcode */
@media screen and (max-width: 768px) {
    .gbp-filter-row   { flex-direction: column; }
    .gbp-filter-field { flex: 1 1 100%; width: 100%; }
    .gbp-filter-actions { width: 100%; justify-content: flex-start; }

    .gbp-preventivi-table { font-size: 13px; }

    .gbp-preventivi-table th,
    .gbp-preventivi-table td { padding: 8px 10px; }

    .gbp-col-totale { text-align: left; }
}

@media screen and (max-width: 600px) {
    .gbp-preventivi-table thead { display: none; }

    .gbp-preventivi-table,
    .gbp-preventivi-table tbody,
    .gbp-preventivi-table tr,
    .gbp-preventivi-table td {
        display: block;
        width: 100%;
    }

    .gbp-preventivi-table tr {
        margin-bottom: 12px;
        border: 1px solid #e0e4e8;
        border-radius: 8px;
        overflow: hidden;
    }

    .gbp-preventivi-table td {
        position: relative;
        padding-left: 48%;
        border: none;
        border-bottom: 1px solid #f0f2f5;
    }

    .gbp-preventivi-table td:last-child { border-bottom: none; }

    .gbp-preventivi-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: 700;
        font-size: 11px;
        text-transform: uppercase;
        color: #6b7280;
        letter-spacing: 0.04em;
    }

    .gbp-col-azioni { text-align: left; }
}
