/**
 * SparkPlus Internal Linking Tab Styles
 */

.sparkplus-interlinking-container {
    margin-top: 20px;
}

.sparkplus-interlinking-header {
    margin-bottom: 20px;
}

.sparkplus-interlinking-header h2 {
    margin-top: 0;
    color: #1d2327;
    font-size: 23px;
    font-weight: 400;
    margin-bottom: 8px;
}

.sparkplus-interlinking-header .description {
    font-size: 14px;
    color: #646970;
}

/* Linking Options */
.sparkplus-linking-options {
    background: #f0f0f1;
    border-left: 4px solid #2271b1;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 4px;
}

.sparkplus-option-group {
    margin-bottom: 20px;
}

.sparkplus-option-group:last-child {
    margin-bottom: 0;
}

.sparkplus-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 8px;
}

.sparkplus-checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.sparkplus-option-title {
    font-weight: 600;
    color: #1d2327;
    font-size: 14px;
    line-height: 1.4;
}

.sparkplus-option-group .description {
    margin-left: 30px;
    margin-top: 0;
    color: #646970;
    font-size: 13px;
}

.sparkplus-interlinking-content {
    display: grid;
    gap: 30px;
}

/* Sections */
.sparkplus-interlinking-section {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    overflow: hidden;
}

.sparkplus-interlinking-section-header {
    padding: 20px;
    background: #f6f7f7;
    border-bottom: 1px solid #c3c4c7;
}

.sparkplus-interlinking-section-header h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sparkplus-interlinking-section-header h3 .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #2271b1;
}

.sparkplus-interlinking-section-header .description {
    margin: 0;
    color: #646970;
    font-size: 13px;
}

/* Tree View Styles */
.sparkplus-tree-container {
    padding: 20px;
}

.sparkplus-tree-item {
    margin: 0;
}

.sparkplus-tree-folder {
    border-bottom: 1px solid #f0f0f1;
}

.sparkplus-tree-folder:last-child {
    border-bottom: none;
}

.sparkplus-tree-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    gap: 8px;
}

.sparkplus-tree-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 3px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sparkplus-tree-toggle:hover {
    background: #f0f0f1;
}

.sparkplus-tree-toggle .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: #50575e;
    transition: transform 0.2s;
}

.sparkplus-tree-folder.expanded .sparkplus-tree-toggle .dashicons {
    transform: rotate(90deg);
}

.sparkplus-tree-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background 0.15s;
    user-select: none;
}

.sparkplus-tree-label:hover {
    background: #f6f7f7;
}

.sparkplus-tree-checkbox {
    margin: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    position: relative;
}

.sparkplus-tree-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sparkplus-tree-icon .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #646970;
}

.sparkplus-tree-text {
    font-size: 14px;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sparkplus-tree-count {
    font-size: 12px;
    color: #646970;
    font-weight: normal;
}

.sparkplus-tree-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 8px;
    background: #f0f0f1;
    border-radius: 10px;
    color: #50575e;
}

.sparkplus-tree-badge.sparkplus-tree-loading {
    background: transparent;
    padding: 0;
}

.sparkplus-tree-badge .spinner {
    float: none;
    margin: 0;
}

/* Tree Children (nested items) */
.sparkplus-tree-children {
    padding-left: 32px;
    border-left: 2px solid #f0f0f1;
    margin-left: 20px;
}

.sparkplus-tree-children .sparkplus-tree-item {
    border-bottom: 1px solid #f6f7f7;
    padding: 4px 0;
}

.sparkplus-tree-children .sparkplus-tree-item:last-child {
    border-bottom: none;
}

.sparkplus-tree-children .sparkplus-tree-row {
    padding: 6px 0;
}

.sparkplus-tree-children .sparkplus-tree-label {
    padding: 4px 6px;
}

.sparkplus-tree-children .sparkplus-tree-text {
    font-size: 13px;
}

.sparkplus-tree-children .sparkplus-tree-icon .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #a7aaad;
}

/* Indeterminate checkbox state */
.sparkplus-tree-checkbox:indeterminate::before {
    content: '';
    display: block;
    width: 10px;
    height: 2px;
    background: #2271b1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Empty state in tree */
.sparkplus-tree-empty {
    padding: 20px;
    text-align: center;
    color: #646970;
    font-size: 13px;
}

/* Custom Links Section */

.sparkplus-custom-links-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.sparkplus-custom-links-title {
    flex: 1;
}

.sparkplus-toggle-custom-links {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    margin-top: 0;
}

.sparkplus-toggle-custom-links .dashicons {
    transition: transform 0.2s ease;
}

.sparkplus-custom-links-section.expanded .sparkplus-toggle-custom-links .dashicons {
    transform: rotate(180deg);
}

.sparkplus-toggle-custom-links .sparkplus-toggle-text {
    font-size: 13px;
}

.sparkplus-custom-links-container {
    padding: 20px;
}

.sparkplus-custom-link-form {
    background: #f6f7f7;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.sparkplus-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: end;
}

.sparkplus-form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sparkplus-form-field-full {
    grid-column: 1 / -1;
}

.sparkplus-form-field-button {
    display: flex;
    align-items: flex-end;
}

.sparkplus-form-field label {
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sparkplus-form-field label .description {
    font-weight: normal;
    color: #646970;
    font-size: 12px;
}

.sparkplus-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1.5;
}

.sparkplus-input:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Custom Links List */
.sparkplus-custom-links-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sparkplus-custom-link-item {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 15px;
    transition: border-color 0.15s;
}

.sparkplus-custom-link-item:hover {
    border-color: #2271b1;
}

.sparkplus-custom-link-info {
    flex: 1;
}

.sparkplus-custom-link-title {
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 4px;
    font-size: 14px;
}

.sparkplus-custom-link-url {
    font-size: 12px;
    color: #646970;
    word-break: break-all;
    margin-bottom: 6px;
}

.sparkplus-custom-link-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.sparkplus-keyword-tag {
    display: inline-block;
    background: #f0f0f1;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    color: #50575e;
}

.sparkplus-custom-link-remove {
    background: transparent;
    border: none;
    color: #b32d2e;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 3px;
    font-size: 13px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.sparkplus-custom-link-remove:hover {
    background: #b32d2e;
    color: #fff;
}

.sparkplus-custom-link-remove .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Empty State */
.sparkplus-empty-state {
    text-align: center;
    padding: 40px 20px;
    background: #f6f7f7;
    border: 2px dashed #c3c4c7;
    border-radius: 4px;
}

.sparkplus-empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #c3c4c7;
    margin-bottom: 10px;
}

.sparkplus-empty-state p {
    margin: 0;
    color: #646970;
    font-size: 14px;
}

/* Footer */
.sparkplus-interlinking-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #c3c4c7;
    display: flex;
    align-items: center;
    gap: 15px;
}

.sparkplus-save-status {
    font-size: 14px;
    color: #646970;
}

.sparkplus-save-status.success {
    color: #00a32a;
    font-weight: 600;
}

.sparkplus-save-status.error {
    color: #b32d2e;
    font-weight: 600;
}

/* Button enhancements */
.button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    vertical-align: middle;
    margin-top: -2px;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .sparkplus-form-grid {
        grid-template-columns: 1fr;
    }
    
    .sparkplus-tree-children {
        padding-left: 20px;
        margin-left: 12px;
    }
}
