/**
 * Silva CRM - Admin Styles
 * Professional styling for all CRM admin pages
 */

/* ===================================
   CRITICAL FIX - Force Visibility
   =================================== */

/* Hide WordPress overlays that block the form */
#wp-responsive-overlay,
#wp-auth-check-bg,
#wp-auth-check {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Force all metabox elements to be visible */
.wrap #poststuff,
.wrap #post-body,
.wrap #post-body-content,
.wrap .postbox,
.wrap .inside,
.wrap .form-table {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: auto !important;
    height: auto !important;
    overflow: visible !important;
}

.metabox-holder {
    display: block !important;
    visibility: visible !important;
}

/* Fix postbox handles covering content */
.postbox .hndle,
.postbox .handlediv {
    position: relative !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    z-index: 1 !important;
}

.postbox .inside {
    position: relative !important;
    z-index: 2 !important;
    clear: both !important;
}

/* Status Badges */

.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

.status-draft { 
    background: #f3f4f6; 
    color: #374151;
    border: 1px solid #d1d5db;
}

.status-sent { 
    background: #dbeafe; 
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.status-accepted { 
    background: #d1fae5; 
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.status-declined { 
    background: #fee2e2; 
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.status-expired { 
    background: #fef3c7; 
    color: #92400e;
    border: 1px solid #fcd34d;
}

.status-paid {
    background: #d1fae5; 
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.status-partial {
    background: #fef3c7; 
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ===================================
   Price Book Type Badges
   =================================== */

.price-book-type-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.type-service { 
    background: #dbeafe; 
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.type-material { 
    background: #fef3c7; 
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* ===================================
   Tables
   =================================== */

.silva-crm-page .wp-list-table {
    border: 1px solid #dcdcde;
    border-radius: 6px;
    overflow: hidden;
}

.silva-crm-page .wp-list-table thead th {
    background: linear-gradient(to bottom, #f9f9f9, #f1f1f1);
    border-bottom: 2px solid #dcdcde;
    font-weight: 600;
    padding: 12px;
}

.silva-crm-page .wp-list-table tbody tr {
    transition: background-color 0.15s ease;
}

.silva-crm-page .wp-list-table tbody tr:hover {
    background-color: #f6f7f7;
}

.silva-crm-page .wp-list-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f1;
}

.silva-crm-page .wp-list-table a {
    color: #2271b1;
    text-decoration: none;
    transition: color 0.15s ease;
}

.silva-crm-page .wp-list-table a:hover {
    color: #135e96;
    text-decoration: underline;
}

.silva-crm-page .wp-list-table tfoot th {
    background: #f9f9f9;
    font-weight: 600;
    padding: 12px;
}

/* ===================================
   Info Box for New Estimates
   =================================== */

.silva-info-box {
    border-left: 4px solid #2271b1 !important;
    background: linear-gradient(to right, #f0f6fc, #ffffff);
}

.silva-info-box .hndle {
    background: transparent !important;
    border-bottom: 1px solid #c3e4f7 !important;
    color: #135e96;
    font-size: 15px;
}

.silva-checklist {
    list-style: none;
    padding-left: 0;
    margin: 15px 0;
}

.silva-checklist li {
    padding: 10px 0 10px 30px;
    position: relative;
    color: #2c3338;
    font-size: 14px;
    line-height: 1.6;
}

.silva-checklist li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #00a32a;
    font-weight: bold;
    font-size: 16px;
}

.silva-tip-box {
    background: #fff9e6;
    border: 1px solid #f0d580;
    border-radius: 4px;
    padding: 12px 15px;
    margin-top: 15px;
    color: #705200;
}

.silva-tip-box strong {
    color: #946200;
}

/* ===================================
   Summary Tables
   =================================== */

.silva-crm-page .estimate-summary-table,
.silva-crm-page .invoice-summary-table {
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    border: 1px solid #dcdcde;
    border-radius: 6px;
}

.silva-crm-page .estimate-summary-table tr,
.silva-crm-page .invoice-summary-table tr {
    border-bottom: 1px solid #f0f0f1;
}

.silva-crm-page .estimate-summary-table tr:last-child,
.silva-crm-page .invoice-summary-table tr:last-child {
    border-bottom: none;
}

.silva-crm-page .estimate-summary-table th,
.silva-crm-page .invoice-summary-table th {
    text-align: right;
    padding: 12px 15px;
    font-weight: 600;
    color: #1d2327;
    background: #f9f9f9;
}

.silva-crm-page .estimate-summary-table td,
.silva-crm-page .invoice-summary-table td {
    padding: 12px 15px;
    text-align: right;
    font-size: 15px;
}

.silva-crm-page .estimate-summary-table .total-row th,
.silva-crm-page .invoice-summary-table .total-row th {
    background: #f0f6fc;
    color: #135e96;
    font-size: 16px;
    border-top: 2px solid #2271b1;
}

.silva-crm-page .estimate-summary-table .total-row td,
.silva-crm-page .invoice-summary-table .total-row td {
    background: #f0f6fc;
    font-weight: 700;
    font-size: 18px;
    color: #135e96;
    border-top: 2px solid #2271b1;
}

/* ===================================
   Action Buttons
   =================================== */

.silva-crm-page .button-primary {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    font-weight: 600;
    transition: all 0.2s ease;
}

.silva-crm-page .button-primary:hover {
    background: #135e96;
    border-color: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.silva-crm-page .button-secondary {
    border-color: #2271b1;
    color: #2271b1;
    transition: all 0.2s ease;
}

.silva-crm-page .button-secondary:hover {
    background: #f0f6fc;
    border-color: #135e96;
    color: #135e96;
}

/* ===================================
   Notices/Messages
   =================================== */

.silva-crm-page .notice {
    border-left-width: 4px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.silva-crm-page .notice-success {
    border-left-color: #00a32a;
    background: #e7f7ed;
}

.silva-crm-page .notice-info {
    border-left-color: #2271b1;
    background: #f0f6fc;
}

.silva-crm-page .notice-warning {
    border-left-color: #dba617;
    background: #fcf9e8;
}

.silva-crm-page .notice-error {
    border-left-color: #d63638;
    background: #fcf0f1;
}

/* ===================================
   Responsive Design
   =================================== */

@media screen and (max-width: 782px) {
    .silva-crm-page .form-table th {
        width: auto;
        padding: 10px 0;
    }
    
    .silva-crm-page .form-table td {
        padding: 10px 0;
    }
    
    .silva-crm-page .estimate-summary-table,
    .silva-crm-page .invoice-summary-table {
        max-width: 100%;
    }
}

/* ===================================
   Loading States
   =================================== */

.silva-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.silva-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: silva-spin 1s linear infinite;
}

@keyframes silva-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================
   Two Column Layout
   =================================== */

.silva-crm-page #post-body.columns-2 {
    margin-right: 320px;
}

.silva-crm-page #post-body-content {
    margin-right: 0;
}

.silva-crm-page #postbox-container-1 {
    width: 300px;
    float: right;
}

@media screen and (max-width: 1200px) {
    .silva-crm-page #post-body.columns-2 {
        margin-right: 0;
    }
    
    .silva-crm-page #postbox-container-1 {
        width: 100%;
        float: none;
        margin-top: 20px;
    }
}

/* ===================================
   Fast Entry Form
   =================================== */

.silva-estimate-fast-entry .silva-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.silva-estimate-fast-entry .silva-field {
    display: flex;
    flex-direction: column;
}

.silva-estimate-fast-entry .silva-field label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #1d2327;
    font-size: 13px;
}

.silva-estimate-fast-entry .silva-field input,
.silva-estimate-fast-entry .silva-field select,
.silva-estimate-fast-entry .silva-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
}

.silva-estimate-fast-entry .silva-field-full {
    grid-column: 1 / -1;
}

.silva-estimate-fast-entry .silva-required label::after {
    content: " *";
    color: #d63638;
}

.silva-estimate-fast-entry .silva-optional {
    color: #8c8f94;
    font-weight: normal;
    font-size: 12px;
}

.silva-estimate-fast-entry .silva-read-only {
    padding: 8px 10px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-weight: 600;
    color: #2271b1;
}

/* Collapsible Sections */
.silva-collapsible {
    margin-top: 20px;
    border-top: 1px solid #dcdcde;
    padding-top: 15px;
}

.silva-collapse-toggle {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #2271b1;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.silva-collapse-toggle:hover {
    background: #f6f7f7;
}

.silva-collapse-toggle .dashicons {
    margin-right: 5px;
    transition: transform 0.2s;
}

.silva-collapsible:not(.collapsed) .silva-collapse-toggle .dashicons {
    transform: rotate(180deg);
}

.silva-collapse-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 15px 0 0 0;
}

.silva-collapsible.collapsed .silva-collapse-content {
    max-height: 0;
    padding: 0;
}

.silva-advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

/* ===================================
   Inline Items Table
   =================================== */

.silva-items-section .postbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
}

.silva-items-section .hndle {
    margin: 0;
    padding: 0;
}

.silva-items-section .handle-actions {
    display: flex;
    gap: 8px;
}

.silva-items-table-wrapper {
    overflow-x: auto;
}

.silva-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.silva-items-table thead th {
    background: #f9f9f9;
    border-bottom: 2px solid #dcdcde;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
    position: sticky;
    top: 0;
    z-index: 10;
}

.silva-items-table tbody tr {
    border-bottom: 1px solid #f0f0f1;
    transition: background 0.15s;
}

.silva-items-table tbody tr:hover {
    background: #f6f7f7;
}

.silva-items-table td {
    padding: 8px;
    vertical-align: middle;
}

.silva-items-table input[type="text"],
.silva-items-table input[type="number"],
.silva-items-table select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    font-size: 13px;
}

.silva-items-table input[type="text"]:focus,
.silva-items-table input[type="number"]:focus,
.silva-items-table select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

.silva-items-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.silva-items-table .silva-row-number {
    text-align: center;
    font-weight: 600;
    color: #8c8f94;
}

.silva-items-table .item-total {
    font-weight: 600;
    color: #135e96;
    text-align: right;
}

.silva-items-table .text-center {
    text-align: center;
}

.silva-items-table .text-right {
    text-align: right;
}

.silva-items-table .remove-item {
    color: #d63638;
    padding: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.silva-items-table .remove-item:hover {
    color: #8a1c1c;
}

.silva-items-table tfoot tr {
    background: #f9f9f9;
    font-weight: 600;
}

.silva-items-table tfoot td {
    padding: 12px 8px;
    border-top: 2px solid #dcdcde;
}

.silva-items-help {
    margin-top: 15px;
    padding: 10px 15px;
    background: #f0f6fc;
    border-left: 4px solid #2271b1;
    border-radius: 4px;
}

.silva-items-help p {
    margin: 0;
    font-size: 13px;
    color: #1d2327;
}

.silva-items-help kbd {
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 11px;
}

/* Autocomplete Dropdown */
.silva-autocomplete-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    min-width: 250px;
}

.silva-autocomplete-dropdown.active {
    display: block;
}

.silva-autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
}

.silva-autocomplete-item:last-child {
    border-bottom: none;
}

.silva-autocomplete-item:hover,
.silva-autocomplete-item.selected {
    background: #f0f6fc;
}

.silva-autocomplete-item strong {
    display: block;
    color: #1d2327;
}

.silva-autocomplete-item small {
    display: block;
    color: #8c8f94;
    margin-top: 2px;
}

.silva-autocomplete-item .price {
    color: #135e96;
    font-weight: 600;
}

/* ===================================
   Sticky Summary Sidebar
   =================================== */

.silva-sticky-summary {
    position: sticky;
    top: 32px;
}

.silva-summary-table {
    width: 100%;
    border-collapse: collapse;
}

.silva-summary-table tr {
    border-bottom: 1px solid #f0f0f1;
}

.silva-summary-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: #1d2327;
}

.silva-summary-table td {
    text-align: right;
    padding: 10px 12px;
    font-size: 16px;
    font-weight: 600;
    color: #135e96;
}

.silva-summary-table .total-row th,
.silva-summary-table .total-row td {
    background: #f0f6fc;
    border-top: 2px solid #2271b1;
    font-size: 18px;
    padding: 15px 12px;
}

.silva-summary-table .silva-discount-row td {
    color: #d63638;
}

.silva-sidebar-field {
    margin-bottom: 15px;
}

.silva-sidebar-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #1d2327;
    font-size: 13px;
}

.silva-sidebar-field input,
.silva-sidebar-field select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
}

/* ===================================
   Animations
   =================================== */

@keyframes silva-highlight-fade {
    0% {
        background-color: #fff9c4;
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.silva-highlight {
    animation: silva-highlight-fade 0.8s ease-out;
}

.silva-items-table tr.silva-item-row {
    transition: all 0.3s ease;
}

.silva-items-table tr.silva-item-row:hover {
    transform: translateX(2px);
}

/* ===================================
   Mobile Responsive
   =================================== */

@media screen and (max-width: 782px) {
    .silva-estimate-fast-entry .silva-quick-grid,
    .silva-estimate-fast-entry .silva-advanced-grid {
        grid-template-columns: 1fr;
    }
    
    .silva-items-table {
        font-size: 12px;
    }
    
    .silva-items-table input,
    .silva-items-table select {
        font-size: 12px;
        padding: 4px 6px;
    }
    
    .silva-items-table thead th {
        padding: 8px 4px;
        font-size: 11px;
    }
    
    .silva-items-table td {
        padding: 6px 4px;
    }
    
    .silva-sticky-summary {
        position: static;
    }
    
    /* Touch-friendly controls */
    .silva-items-table .remove-item {
        padding: 8px;
    }
    
    .silva-items-table input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }
    
    #add-item-row {
        width: 100%;
        padding: 12px;
    }
}

/* ===================================
   LEAD APPOINTMENT SCHEDULING
   =================================== */

/* Make date and time inputs more user-friendly */
input[type="date"],
input[type="time"] {
    min-height: 40px !important;
    padding: 8px 12px !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
    border: 2px solid #ddd !important;
    border-radius: 4px !important;
    width: 100% !important;
    max-width: 300px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

input[type="date"]:hover,
input[type="time"]:hover {
    border-color: #999 !important;
}

input[type="date"]:focus,
input[type="time"]:focus {
    border-color: #2271b1 !important;
    box-shadow: 0 0 0 1px #2271b1 !important;
    outline: none !important;
}

/* Calendar icon styling - make it easier to see */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    margin-left: 8px;
    opacity: 0.7;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background-color: #f0f0f0;
    border-radius: 4px;
}

/* Add visual feedback for filled fields */
input[type="date"]:valid,
input[type="time"]:valid {
    background-color: #f0f9ff;
    border-color: #0891b2;
}

/* Mobile improvements */
@media (max-width: 782px) {
    input[type="date"],
    input[type="time"] {
        min-height: 48px !important;
        font-size: 18px !important;
    }
}

/* ===================================
   Mobile Customer Name Visibility
   Improves readability on small screens
   =================================== */
@media (max-width: 768px) {

    /* ---- Filter bar: stack vertically ---- */
    .silva-crm-page .wrap > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }
    .silva-crm-page .wrap > div[style*="display: flex"] > div { width: 100% !important; }
    .silva-crm-page .wrap > div[style*="display: flex"] select,
    .silva-crm-page .wrap > div[style*="display: flex"] input[type="text"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* ---- Card layout for leads table ---- */
    #leads-table,
    #leads-table tbody,
    #leads-table tr,
    #leads-table td {
        display: block !important;
        width: 100% !important;
    }

    /* Hide the column headers row */
    #leads-table thead { display: none !important; }

    /* Each row becomes a card */
    #leads-table tbody tr.lead-row {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin: 0 0 10px 0 !important;
        padding: 12px 14px !important;
        box-shadow: 0 1px 4px rgba(0,0,0,.07);
        cursor: pointer;
    }
    #leads-table tbody tr.lead-row:hover {
        border-color: #2271b1;
        box-shadow: 0 2px 8px rgba(34,113,177,.15);
    }

    /* All cells: no border, no padding override */
    #leads-table td {
        border: none !important;
        padding: 3px 0 !important;
        font-size: 13px;
        box-shadow: none !important;
    }

    /* Show data-label as an inline prefix */
    #leads-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #6b7280;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .4px;
        margin-right: 4px;
    }

    /* Name cell: no label, full-width header look */
    #leads-table td:first-child {
        padding-bottom: 8px !important;
        border-bottom: 1px solid #f3f4f6 !important;
        margin-bottom: 6px !important;
    }
    #leads-table td:first-child::before { display: none; }
    #leads-table td:first-child strong {
        font-size: 16px !important;
        font-weight: 700 !important;
        color: #1e293b !important;
    }

    /* Hide low-priority columns on mobile */
    #leads-table td[data-label="Address"],
    #leads-table td[data-label="Assigned To"],
    #leads-table td[data-label="Created"] {
        display: none !important;
    }

    /* Actions: right-aligned, no label */
    #leads-table td:last-child {
        padding-top: 8px !important;
        border-top: 1px solid #f3f4f6 !important;
        margin-top: 4px !important;
        text-align: right;
    }
    #leads-table td:last-child::before { display: none; }
}

/* ============================================================================
   Silva CRM - Email Validation & Failed Emails UI  (v4.2.0)
   ============================================================================ */

/* ── Inline email validation indicators ─────────────────────────────────── */
.silva-email-wrap {
    position: relative;
    display: inline-block;
    width: 100%;
}

.silva-email-indicator {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    font-weight: 600;
    pointer-events: none;
    line-height: 1;
}

.silva-email-valid    { color: #16a34a; }
.silva-email-warning  { color: #d97706; }
.silva-email-invalid  { color: #dc2626; }

.silva-email-suggestion {
    font-size: 12px;
    margin-top: 4px;
    padding: 5px 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 4px;
    color: #92400e;
}
.silva-email-suggestion a {
    color: #1d4ed8;
    text-decoration: underline;
    cursor: pointer;
}

/* ── Failed Emails admin page ────────────────────────────────────────────── */
#silva-failed-emails-page .description {
    color: #6b7280;
    margin-bottom: 16px;
}

.silva-failed-email-toolbar {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
}

.silva-failed-emails-table {
    margin-top: 8px;
}
.silva-failed-emails-table th {
    font-weight: 600;
    background: #f9fafb;
}

.silva-email-code {
    font-size: 12px;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 3px;
    color: #111827;
    word-break: break-all;
}
.silva-reason-text {
    color: #6b7280;
    font-size: 11px;
}

/* Type badges */
.silva-type-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}
.silva-badge-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}
.silva-badge-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.silva-badge-resolved {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}
.silva-badge-open {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}
.silva-badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    background: #dc2626;
    color: #fff;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
    padding: 0 6px;
    margin-left: 8px;
    vertical-align: middle;
}

.silva-action-cell {
    white-space: nowrap;
}
.silva-muted {
    color: #9ca3af;
    font-size: 12px;
}
.silva-row-highlight {
    background: #fffbeb !important;
    outline: 2px solid #fbbf24;
}

.silva-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}
.silva-empty-icon {
    display: block;
    font-size: 48px;
    margin-bottom: 12px;
}

/* Webhook config table */
.silva-webhook-config-table td code {
    font-size: 13px;
    padding: 4px 10px;
    background: #f3f4f6;
    border-radius: 4px;
    user-select: all;
}
.silva-webhook-config-table .button {
    margin-left: 8px;
    vertical-align: middle;
}

/* ── Shared modal overlay ────────────────────────────────────────────────── */
.silva-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.silva-modal-box {
    background: #fff;
    border-radius: 8px;
    padding: 28px 32px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    position: relative;
}
.silva-modal-box h2 {
    margin: 0 0 14px;
    font-size: 18px;
    color: #111827;
}
.silva-modal-box p {
    color: #374151;
    margin-bottom: 18px;
    line-height: 1.6;
}
.silva-modal-box .large-text {
    width: 100%;
    font-size: 15px;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
}
.silva-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Pipeline bounce badge ───────────────────────────────────────────────── */
.silva-email-bounce-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 10px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.silva-email-bounce-badge:hover {
    background: #fecaca;
}

/* ============================================================================
   Calculator Settings Admin — Responsive (v4.4.3)
   Affects: wp-admin Calculator Settings page (silva-crm-calculator-settings)
   ============================================================================ */

/* ── Base utility classes added by the template ─────────────────────────── */

/* Disabled rate row — greyed out in admin table */
.silva-rate-disabled td {
    opacity: 0.45;
}
.silva-rate-disabled td:last-child {
    opacity: 1; /* keep action buttons full opacity */
}

/* Enable/Disable button */
.silva-toggle-rate-btn { min-width: 68px; }

/* Delete button — only shown/enabled when row is disabled */
.silva-delete-rate-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.silva-delete-rate-btn.silva-btn-can-delete {
    color: #dc2626 !important;
    border-color: #dc2626 !important;
}

/* Add Item form — default grid layout */
.silva-add-rate-form {
    margin-top: 12px;
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.silva-add-rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}
.silva-add-rate-grid label { font-size: 12px; color: #374151; display: block; margin-bottom: 3px; }
.silva-add-rate-grid input,
.silva-add-rate-grid select { width: 100%; box-sizing: border-box; }
.silva-form-message { display: none; font-size: 13px; margin-top: 6px; }

/* ── Tablet  (≤1024px) ───────────────────────────────────────────────────── */
@media screen and (max-width: 1024px) {

    /* Shrink description column — make room on narrower admin panel */
    .silva-calc-settings-table th:nth-child(4),
    .silva-calc-settings-table td:nth-child(4) {
        display: none;
    }

    /* Compact action buttons — stack vertically */
    .silva-calc-settings-table .silva-action-group {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    .silva-calc-settings-table .silva-action-group .button {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    /* Add form — 2-col grid on tablet */
    .silva-add-rate-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Mobile  (≤600px) ────────────────────────────────────────────────────── */
@media screen and (max-width: 600px) {

    /* Transform table to card-per-row layout */
    .silva-calc-settings-table,
    .silva-calc-settings-table tbody,
    .silva-calc-settings-table tr,
    .silva-calc-settings-table td {
        display: block;
        width: 100%;
    }
    .silva-calc-settings-table thead { display: none; }

    .silva-calc-settings-table tr {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 10px 14px;
        box-sizing: border-box;
    }

    .silva-calc-settings-table td {
        padding: 4px 0;
        border: none;
    }

    /* Show data labels pulled from th text via JS */
    .silva-calc-settings-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        color: #9ca3af;
        margin-right: 4px;
    }

    /* Description always hidden on phone */
    .silva-calc-settings-table td:nth-child(4) { display: none; }

    /* Action column */
    .silva-calc-settings-table td:last-child::before { display: none; }
    .silva-calc-settings-table .silva-action-group {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        margin-top: 6px;
    }

    /* Add form — single column */
    .silva-add-rate-grid {
        grid-template-columns: 1fr;
    }
}

