/* SheetLink Forms Admin Styles */

/* Edition Badge */
.slwp-edition-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    vertical-align: middle;
    margin-left: 10px;
    letter-spacing: 0.02em;
}
.slwp-edition-free {
    background: #f0f0f0;
    color: #646970;
}
.slwp-edition-agency {
    background: #e7f3ff;
    color: #0073aa;
}

/* Free Edition — Upgrade page feature lists */
.slwp-free-features,
.slwp-agency-features {
    list-style: none;
    padding: 0;
    margin: 12px 0 16px;
}
.slwp-free-features li::before {
    content: "\2713";
    color: #00a32a;
    font-weight: bold;
    margin-right: 8px;
}
.slwp-agency-features li::before {
    content: "\2022";
    color: #0073aa;
    font-weight: bold;
    margin-right: 8px;
}
.slwp-free-features li,
.slwp-agency-features li {
    padding: 4px 0;
    font-size: 13px;
}

.sheetlink-wrap {
    max-width: 900px;
    margin-top: 20px;
}

/* Header */
.sheetlink-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sheetlink-header h1 {
    margin: 0;
    font-size: 23px;
    font-weight: 400;
}

/* Cards */
.sheetlink-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* Rule Cards */
.sheetlink-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sheetlink-rule-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.sheetlink-rule-body {
    margin-bottom: 12px;
}

.sheetlink-rule-meta {
    margin-bottom: 6px;
    color: #50575e;
    font-size: 13px;
}

.sheetlink-rule-meta span {
    margin-right: 16px;
}

.sheetlink-rule-webhook {
    margin-bottom: 6px;
}

.sheetlink-rule-webhook code {
    font-size: 12px;
    color: #666;
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 3px;
}

.sheetlink-rule-fields {
    color: #50575e;
    font-size: 13px;
}

.sheetlink-rule-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f1;
}

.sheetlink-rule-actions .sheetlink-delete-rule {
    color: #b32d2e;
    border-color: #b32d2e;
}

.sheetlink-rule-actions .sheetlink-delete-rule:hover {
    background: #b32d2e;
    color: #fff;
}

/* Toggle Switch */
.sheetlink-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.sheetlink-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sheetlink-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.2s;
    border-radius: 24px;
}

.sheetlink-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.2s;
    border-radius: 50%;
}

.sheetlink-toggle input:checked + .sheetlink-toggle-slider {
    background-color: #2271b1;
}

.sheetlink-toggle input:checked + .sheetlink-toggle-slider:before {
    transform: translateX(20px);
}

/* Editor */
.sheetlink-editor {
    margin-bottom: 20px;
}

.sheetlink-editor h2 {
    margin-top: 0;
    margin-bottom: 16px;
}

.sheetlink-editor .form-table th {
    width: 140px;
    padding: 12px 10px 12px 0;
}

.sheetlink-editor .form-table td {
    padding: 8px 10px;
}

.sheetlink-editor-actions {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f1;
    margin-top: 8px;
}

/* Field Mapping */
.sheetlink-field-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.sheetlink-field-header {
    font-weight: 600;
    font-size: 13px;
    color: #50575e;
}

.sheetlink-field-row span {
    flex: 1;
}

.sheetlink-field-row input {
    flex: 1;
    min-width: 0;
}

.sheetlink-field-row .sheetlink-remove-field {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    padding: 0;
    text-align: center;
    line-height: 28px;
    color: #b32d2e;
    border-color: #b32d2e;
    cursor: pointer;
    background: none;
    border: 1px solid;
    border-radius: 3px;
}

.sheetlink-field-row .sheetlink-remove-field:hover {
    background: #b32d2e;
    color: #fff;
}

#sheetlink-add-field {
    margin-top: 4px;
}

/* Empty State */
.sheetlink-empty {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    color: #646970;
    margin-bottom: 16px;
}

/* Log Section */
.sheetlink-log-section {
    margin-top: 30px;
}

.sheetlink-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sheetlink-log-header h2 {
    margin: 0;
}

.sheetlink-log-table {
    margin-top: 0;
}

.sheetlink-log-status {
    width: 50px;
    text-align: center;
}

.sheetlink-status-ok {
    color: #00a32a;
    font-size: 16px;
    font-weight: bold;
}

.sheetlink-status-fail {
    color: #d63638;
    font-size: 16px;
    font-weight: bold;
}

.sheetlink-log-empty {
    color: #646970;
    font-style: italic;
}

tr.sheetlink-log-failed {
    background-color: #fcf0f1 !important;
}

/* Modal */
.sheetlink-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sheetlink-modal-content {
    background: #fff;
    border-radius: 4px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.sheetlink-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #dcdcde;
}

.sheetlink-modal-header h2 {
    margin: 0;
}

.sheetlink-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.sheetlink-modal-close:hover {
    color: #d63638;
}

.sheetlink-modal-body {
    padding: 20px;
}

.sheetlink-modal-body ol {
    margin: 10px 0 20px;
    padding-left: 20px;
}

.sheetlink-modal-body ol li {
    margin-bottom: 4px;
}

#sheetlink-script-code {
    width: 100%;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    padding: 12px;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    background: #f6f7f7;
    resize: vertical;
    margin-bottom: 12px;
}

#sheetlink-copy-status {
    color: #00a32a;
    font-weight: 600;
    margin-left: 10px;
}

/* Notice */
.sheetlink-notice {
    padding: 10px 16px;
    margin-bottom: 16px;
    border-left: 4px solid #2271b1;
    background: #fff;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.sheetlink-notice.sheetlink-notice-success {
    border-left-color: #00a32a;
}

.sheetlink-notice.sheetlink-notice-error {
    border-left-color: #d63638;
}

/* Disabled rule card */
.sheetlink-rule-card.sheetlink-disabled {
    opacity: 0.6;
}

/* Spinner */
.sheetlink-loading .button {
    pointer-events: none;
    opacity: 0.6;
}

/* =========================================
   Dashboard Metrics (Feature 4)
   ========================================= */

.sheetlink-metrics,
.sheetlink-queue-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.sheetlink-metric-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.sheetlink-metric-icon .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #2271b1;
}

.sheetlink-metric-primary {
    border-left: 4px solid #2271b1;
}

.sheetlink-metric-savings {
    border-left: 4px solid #00a32a;
}

.sheetlink-metric-savings .dashicons {
    color: #00a32a;
}

.sheetlink-metric-warning {
    border-left: 4px solid #dba617;
}

.sheetlink-metric-warning .dashicons {
    color: #dba617;
}

.sheetlink-metric-data {
    display: flex;
    flex-direction: column;
}

.sheetlink-metric-number {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: #1d2327;
}

.sheetlink-metric-label {
    font-size: 13px;
    color: #646970;
    margin-top: 2px;
}

/* =========================================
   Settings Row (Enrichment Toggle)
   ========================================= */

.sheetlink-settings-row {
    margin-bottom: 20px;
}

.sheetlink-setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sheetlink-setting-info {
    flex: 1;
    margin-right: 20px;
}

.sheetlink-setting-info strong {
    font-size: 14px;
}

.sheetlink-setting-info .description {
    margin-top: 4px;
}

/* =========================================
   Voquii Upsell Banner (Feature 4)
   ========================================= */

.sheetlink-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 8px;
    padding: 28px 32px;
    margin-bottom: 20px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sheetlink-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.sheetlink-banner-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    color: #a3d9ff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.sheetlink-banner-text h3 {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 6px;
}

.sheetlink-banner-text p {
    color: #b8d4e8;
    font-size: 14px;
    margin: 0;
    max-width: 520px;
    line-height: 1.5;
}

.sheetlink-banner-btn {
    background: #3b82f6 !important;
    border-color: #2563eb !important;
    color: #fff !important;
    font-size: 14px !important;
    padding: 8px 24px !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background 0.2s;
}

.sheetlink-banner-btn:hover {
    background: #2563eb !important;
}

/* =========================================
   Conditional Routing V2
   ========================================= */

.sheetlink-routing-header-v2 {
    display: grid;
    grid-template-columns: 30px 36px 120px 1fr 120px 1fr 100px 1fr 30px;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 12px;
    color: #50575e;
}

.sheetlink-routing-row-v2 {
    display: grid;
    grid-template-columns: 30px 36px 120px 1fr 120px 1fr 100px 1fr 30px;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    border-radius: 3px;
    background: #f9f9f9;
    padding: 6px 4px;
}

.sheetlink-routing-row-v2.slwp-rr-disabled {
    opacity: 0.5;
}

.sheetlink-routing-row-v2 input,
.sheetlink-routing-row-v2 select {
    width: 100%;
    min-width: 0;
    font-size: 12px;
    padding: 4px 6px;
}

.slwp-rr-reorder {
    text-align: center;
}

.slwp-rr-reorder-btns {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.slwp-rr-reorder-btns button {
    width: 24px;
    height: 14px;
    padding: 0;
    font-size: 10px;
    line-height: 12px;
    cursor: pointer;
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 2px;
    color: #50575e;
}

.slwp-rr-reorder-btns button:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.slwp-rr-enabled {
    text-align: center;
}

.slwp-rr-enabled input[type="checkbox"] {
    margin: 0;
    width: auto;
}

.slwp-rr-remove-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    text-align: center;
    line-height: 22px;
    color: #b32d2e;
    border-color: #b32d2e;
    cursor: pointer;
    background: none;
    border: 1px solid;
    border-radius: 3px;
    font-size: 14px;
}

.slwp-rr-remove-btn:hover {
    background: #b32d2e;
    color: #fff;
}

/* Test routing modal */
.slwp-test-routing-result {
    margin-top: 12px;
    padding: 12px;
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
}

.slwp-test-routing-result .slwp-tr-match {
    font-weight: 600;
    color: #2271b1;
}

.slwp-test-routing-result .slwp-tr-fallback {
    color: #dba617;
    font-size: 12px;
    margin-top: 4px;
}

/* Route column in log */
.sheetlink-log-route {
    font-size: 12px;
}

.sheetlink-log-route-default {
    color: #646970;
}

.sheetlink-log-route-matched {
    color: #2271b1;
    font-weight: 500;
}

.sheetlink-log-fallback {
    color: #dba617;
    font-size: 11px;
}

#sheetlink-add-routing {
    margin-top: 4px;
}

.sheetlink-rule-routing {
    color: #2271b1;
    font-size: 12px;
    margin-top: 4px;
}

/* =========================================
   Queue page additions
   ========================================= */

.sheetlink-queue-stats {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 782px) {
    .sheetlink-metrics,
    .sheetlink-queue-stats {
        grid-template-columns: 1fr;
    }

    .sheetlink-banner-content {
        flex-direction: column;
        text-align: center;
    }

    .sheetlink-routing-header-v2,
    .sheetlink-routing-row-v2 {
        grid-template-columns: 1fr;
    }
    .sheetlink-routing-header-v2 {
        display: none;
    }
}

/* ===== License Page ===== */
.slwp-license-card {
    max-width: 560px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 24px 28px;
    margin-top: 16px;
}

.slwp-license-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 100px;
    margin-bottom: 20px;
}

.slwp-license-active {
    background: #ecfdf5;
    color: #065f46;
}

.slwp-license-revoked {
    background: #fef2f2;
    color: #991b1b;
    margin-bottom: 16px;
}

.slwp-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.slwp-status-green { background: #22c55e; }
.slwp-status-red { background: #ef4444; }

.slwp-license-info {
    margin-bottom: 20px;
}

.slwp-license-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f1;
}

.slwp-license-row:last-child {
    border-bottom: none;
}

.slwp-license-label {
    width: 100px;
    font-size: 13px;
    color: #646970;
    font-weight: 500;
}

.slwp-license-value {
    font-size: 14px;
    color: #1d2327;
    font-weight: 600;
}

.slwp-license-tier {
    background: #dbeafe;
    color: #1e40af;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slwp-license-hint {
    font-size: 13px;
    color: #646970;
    margin-bottom: 16px;
}

.slwp-activate-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 16px 0;
}

.slwp-activate-form input[type="email"] {
    flex: 1;
    max-width: 320px;
}

#slwp-activate-message .notice {
    margin: 0;
}

.slwp-upgrade-link {
    display: inline-block;
    margin-top: 8px;
    font-weight: 600;
}

/* =========================================
   Two-Way Sync Page
   ========================================= */

.slwp-tws-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.slwp-tws-status-item {
    background: #f6f7f7;
    padding: 12px 16px;
    border-radius: 6px;
}

.slwp-tws-label {
    display: block;
    font-size: 12px;
    color: #646970;
    margin-bottom: 6px;
    font-weight: 500;
}

.slwp-tws-steps {
    margin: 0;
    padding-left: 20px;
    color: #1d2327;
    font-size: 13px;
    line-height: 1.8;
}

.slwp-tws-steps li {
    margin-bottom: 4px;
}

@media (max-width: 600px) {
    .slwp-tws-status-grid {
        grid-template-columns: 1fr;
    }
}
