/**
 * Genius Commerce Admin Styles
 *
 * @package GeniusCommerce
 */

/* Subtab Navigation - aligned with WooCommerce main tabs */
.gc-subtab-nav {
    margin: 10px 0 20px 20px;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

.gc-subtab-link {
    text-decoration: none;
    color: #2271b1;
    padding: 4px 0;
}

.gc-subtab-link:hover {
    color: #135e96;
}

.gc-subtab-link.gc-subtab-active {
    color: #1d2327;
    font-weight: 600;
}

.gc-subtab-separator {
    color: #c3c4c7;
    margin: 0 8px;
}

/* Status Overview Box */
.gc-status-overview {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-left: 4px solid #2271b1;
    padding: 12px 16px;
    margin-bottom: 20px;
    margin-top: 10px;
}

.gc-status-overview h3 {
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
}

.gc-status-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gc-status-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

.gc-status-ok .dashicons {
    color: #00a32a;
}

.gc-status-missing .dashicons,
.gc-status-unknown .dashicons {
    color: #dba617;
}

.gc-status-error .dashicons {
    color: #d63638;
}

.gc-status-testing .dashicons {
    color: #2271b1;
}

/* Connection Test Button */
.gc-test-connection {
    margin-left: 12px !important;
}

/* Spin animation for loading */
.gc-spin {
    animation: gc-spin 1s linear infinite;
}

@keyframes gc-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Connection text */
.gc-connection-text {
    flex: 1;
}

/* API Key Field */
#genius_commerce_api_key {
    font-family: Consolas, Monaco, monospace;
    width: 350px;
    letter-spacing: 0.5px;
}

/* Toggle Visibility Button */
.gc-toggle-visibility {
    margin-left: 8px !important;
    padding: 0 8px !important;
    min-height: 30px !important;
    vertical-align: middle;
}

.gc-toggle-visibility .dashicons {
    margin-top: 3px;
    width: 20px;
    height: 20px;
    font-size: 20px;
}

/* Backend URL Field */
#genius_commerce_backend_url {
    width: 100%;
    max-width: 500px;
}

/* =====================================================
   Webhook Configuration Section
   ===================================================== */

.gc-webhook-config {
    background: #fff;
    border: 1px solid #c3c4c7;
    padding: 16px 20px;
    margin-top: 20px;
}

/* Webhook Header with Refresh Button */
.gc-webhook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.gc-webhook-header h2 {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
}

.gc-refresh-webhooks {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gc-refresh-webhooks .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-top: 2px;
}

.gc-webhook-config > .description {
    margin: 0 0 16px 0;
    color: #646970;
}

/* Warning Banner */
.gc-webhook-warning {
    margin: 0 0 20px 0;
    padding: 12px 16px;
}

.gc-webhook-warning p {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
}

.gc-webhook-warning .dashicons {
    color: #dba617;
    margin-top: 2px;
}

.gc-webhook-warning small {
    display: block;
    width: 100%;
    margin-top: 4px;
    margin-left: 26px;
    color: #646970;
}

/* Webhook Group */
.gc-webhook-group {
    margin-bottom: 24px;
}

.gc-webhook-group:last-child {
    margin-bottom: 0;
}

.gc-webhook-group h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
}

.gc-webhook-group h3 .button {
    font-size: 11px;
    min-height: 24px;
    line-height: 22px;
    padding: 0 8px;
}

/* Webhook Table */
.gc-webhook-table {
    border: 1px solid #c3c4c7;
    border-radius: 4px;
}

.gc-webhook-table th {
    background: #f6f7f7;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
}

.gc-webhook-table td {
    padding: 10px 12px;
    vertical-align: middle;
}

.gc-webhook-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.gc-col-status {
    width: 100px;
}

.gc-col-topic {
    width: auto;
}

.gc-col-modified {
    width: 140px;
    font-size: 12px;
    color: #646970;
}

.gc-col-failures {
    width: 70px;
    text-align: center;
}

.gc-col-actions {
    width: 150px;
    text-align: right;
}

/* Action buttons container */
.gc-action-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Details link button */
.gc-webhook-details {
    padding: 0 6px !important;
    min-width: 30px;
}

.gc-webhook-details .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin-top: 3px;
}

/* Failure count indicators */
.gc-failure-count {
    display: inline-block;
    min-width: 20px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.gc-failure-warning {
    background: #fff3cd;
    color: #856404;
}

.gc-failure-critical {
    background: #f8d7da;
    color: #721c24;
}

.gc-no-failures {
    color: #8c8f94;
}

.gc-no-data {
    color: #8c8f94;
}

/* Row with failures highlight */
.gc-has-failures {
    background: #fffbf0 !important;
}

/* Topic code display */
.gc-topic-code {
    display: block;
    font-size: 11px;
    color: #8c8f94;
    font-family: Consolas, Monaco, monospace;
    margin-top: 2px;
}

/* Status Badges */
.gc-webhook-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.gc-badge-active {
    background: #d4edda;
    color: #155724;
}

.gc-badge-paused {
    background: #fff3cd;
    color: #856404;
}

.gc-badge-disabled {
    background: #f8d7da;
    color: #721c24;
}

.gc-badge-missing {
    background: #e2e3e5;
    color: #6c757d;
}

.gc-badge-unknown {
    background: #e2e3e5;
    color: #6c757d;
}

/* Not registered text */
.gc-not-registered {
    font-size: 12px;
    color: #8c8f94;
    font-style: italic;
}

/* Responsive adjustments */
@media screen and (max-width: 782px) {
    #genius_commerce_api_key,
    #genius_commerce_backend_url {
        width: 100%;
        max-width: 100%;
    }

    .gc-toggle-visibility {
        margin-top: 8px !important;
        margin-left: 0 !important;
    }

    /* Webhook config mobile styles */
    .gc-webhook-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .gc-webhook-group h3 {
        flex-wrap: wrap;
    }

    .gc-webhook-table th,
    .gc-webhook-table td {
        padding: 8px;
    }

    .gc-col-status {
        width: 80px;
    }

    .gc-col-modified,
    .gc-col-failures {
        display: none;
    }

    .gc-col-actions {
        width: 100px;
    }

    .gc-topic-code {
        display: none;
    }

    .gc-action-buttons {
        flex-direction: column;
        gap: 4px;
    }
}

/* =====================================================
   Template Editor Section
   ===================================================== */

.gc-template-config {
    background: #fff;
    border: 1px solid #c3c4c7;
    padding: 16px 20px;
    margin-top: 20px;
}

.gc-template-config > h2 {
    margin: 0 0 8px 0;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
}

.gc-template-config > .description {
    margin: 0 0 20px 0;
    color: #646970;
}

/* Individual Template Editor */
.gc-template-editor {
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 16px;
    margin-bottom: 20px;
}

.gc-template-editor:last-child {
    margin-bottom: 0;
}

.gc-template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.gc-template-header h3 {
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
}

/* Template Status Badges */
.gc-template-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.gc-status-custom {
    background: #e8f4ff;
    color: #0073aa;
}

.gc-status-default {
    background: #d4edda;
    color: #155724;
}

.gc-template-status .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* Placeholder Help */
.gc-placeholder-help {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 10px 12px;
    margin: 12px 0;
}

.gc-placeholder-help strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: #1d2327;
}

.gc-placeholder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gc-placeholder {
    cursor: help;
}

.gc-placeholder code {
    display: inline-block;
    padding: 2px 8px;
    background: #f0f0f1;
    border-radius: 3px;
    font-size: 11px;
    font-family: Consolas, Monaco, monospace;
    color: #1e1e1e;
}

.gc-placeholder:hover code {
    background: #2271b1;
    color: #fff;
}

/* Template Content Textarea */
.gc-template-content {
    width: 100%;
    min-height: 200px;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    resize: vertical;
}

.gc-template-content:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

/* CodeMirror Wrapper */
.gc-template-editor .CodeMirror {
    border: 1px solid #8c8f94;
    border-radius: 4px;
    height: auto;
    min-height: 200px;
}

.gc-template-editor .CodeMirror-focused {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Template Actions */
.gc-template-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.gc-template-actions .button {
    min-width: 100px;
}

.gc-template-actions .gc-reset-template:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Feedback Messages */
.gc-template-feedback {
    font-size: 13px;
    font-weight: 500;
    padding: 0 8px;
}

.gc-feedback-success {
    color: #00a32a;
}

.gc-feedback-error {
    color: #d63638;
}

/* Theme Override Status Badge */
.gc-status-theme {
    background: #f0f6fc;
    color: #0969da;
}

/* Theme Override Notice */
.gc-template-editor.gc-theme-override {
    background: #f0f6fc;
    border-color: #0969da;
}

.gc-theme-override-notice {
    background: #fff;
    border: 1px solid #d0d7de;
    border-left: 4px solid #0969da;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 4px;
}

.gc-theme-override-notice p {
    margin: 0 0 8px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.gc-theme-override-notice p:last-child {
    margin-bottom: 0;
}

.gc-theme-override-notice .dashicons {
    color: #0969da;
    flex-shrink: 0;
    margin-top: 2px;
}

.gc-theme-override-notice code {
    background: #f6f8fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
}

.gc-theme-override-help {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #d0d7de;
    font-size: 12px;
    color: #656d76;
}

.gc-theme-override-help strong {
    display: block;
    margin-bottom: 4px;
    color: #1f2328;
}

/* Responsive adjustments for template editor */
@media screen and (max-width: 782px) {
    .gc-template-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .gc-placeholder-list {
        gap: 4px;
    }

    .gc-placeholder code {
        font-size: 10px;
        padding: 2px 6px;
    }

    .gc-template-actions {
        flex-wrap: wrap;
    }

    .gc-template-actions .button {
        min-width: auto;
        flex: 1;
    }

    .gc-template-feedback {
        width: 100%;
        margin-top: 8px;
    }
}

/* =====================================================
   Sync Mapping Section
   ===================================================== */

.gc-mapping-config {
    background: #fff;
    border: 1px solid #c3c4c7;
    padding: 16px 20px;
    margin-top: 10px;
}

.gc-mapping-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.gc-mapping-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gc-last-scan {
    font-size: 12px;
    color: #646970;
}

.gc-mapping-actions-bottom {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #dcdcde;
    display: flex;
    align-items: center;
    gap: 12px;
}

.gc-mapping-feedback {
    font-size: 13px;
    font-weight: 500;
}

.gc-mapping-feedback.gc-feedback-success {
    color: #00a32a;
}

.gc-mapping-feedback.gc-feedback-error {
    color: #d63638;
}

.gc-mapping-select {
    min-width: 150px;
}
