/**
 * Basis Tables – Admin Styles
 *
 * @package BasisTables
 */

/* =========================================================================
   LAYOUT & HEADER
   ====================================================================== */

.bt-admin-wrap {
    max-width: 1200px;
}

.bt-admin-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bt-admin-title .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.bt-admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.bt-admin-desc {
    color: #646970;
    font-size: 14px;
    margin: 0;
}

.bt-admin-new-btn .dashicons {
    vertical-align: middle;
    margin-right: 4px;
}

/* =========================================================================
   TABLES LIST
   ====================================================================== */

.bt-admin-loading {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
}

.bt-admin-loading .spinner {
    float: none;
    margin: 0 10px 0 0;
    vertical-align: middle;
}

.bt-tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.bt-table-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    transition: box-shadow 0.2s;
}

.bt-table-card:hover {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
}

.bt-table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.bt-table-card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #1d2327;
}

.bt-table-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #646970;
    margin-bottom: 12px;
}

.bt-table-card-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bt-table-card-meta .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #8c8f94;
}

.bt-table-card-shortcode {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f6f7f7;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.bt-table-card-shortcode code {
    flex: 1;
    font-size: 12px;
    background: none;
    padding: 0;
    word-break: break-all;
}

.bt-table-card-shortcode .button {
    flex-shrink: 0;
    padding: 0 8px;
    min-height: 28px;
    line-height: 26px;
}

.bt-table-card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid #f0f0f1;
    padding-top: 12px;
}

.bt-table-card-actions .button {
    flex: 1;
    text-align: center;
}

.bt-admin-delete-btn {
    color: #b32d2e !important;
    border-color: #b32d2e !important;
}

.bt-admin-delete-btn:hover {
    background: #b32d2e !important;
    color: #fff !important;
}

/* =========================================================================
   EMPTY STATE
   ====================================================================== */

.bt-admin-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
}

.bt-admin-empty-icon .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #c3c4c7;
}

.bt-admin-empty h2 {
    font-size: 20px;
    margin: 16px 0 8px;
}

.bt-admin-empty p {
    color: #646970;
    font-size: 14px;
    margin-bottom: 20px;
}

/* =========================================================================
   MODAL
   ====================================================================== */

.bt-new-modal {
    position: fixed;
    inset: 0;
    z-index: 100100;
    overflow-x: hidden;
    overflow-y: auto;
}

.bt-new-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.bt-new-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    margin: 50px auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.bt-new-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #dcdcde;
}

.bt-new-modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.bt-new-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #646970;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.bt-new-modal-close:hover {
    color: #1d2327;
    background: #f0f0f1;
}

.bt-new-modal-body {
    padding: 24px;
}

/* =========================================================================
   STEPS
   ====================================================================== */

.bt-steps {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 24px;
}

.bt-step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8c8f94;
    font-size: 13px;
}

.bt-step-active {
    color: #2271b1;
    font-weight: 600;
}

.bt-step-done {
    color: #00a32a;
}

.bt-step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.bt-step-active .bt-step-number {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.bt-step-done .bt-step-number {
    background: #00a32a;
    color: #fff;
    border-color: #00a32a;
}

/* =========================================================================
   UPLOAD AREA
   ====================================================================== */

.bt-upload-area {
    border: 2px dashed #c3c4c7;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 16px;
}

.bt-upload-area:hover,
.bt-upload-area.bt-drag-over {
    border-color: #2271b1;
    background: #f0f7fc;
}

.bt-upload-icon .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #8c8f94;
}

.bt-upload-text {
    font-size: 15px;
    margin: 12px 0 4px;
    color: #1d2327;
}

.bt-upload-hint {
    font-size: 13px;
    color: #646970;
    margin: 0;
}

.bt-upload-progress {
    margin-top: 16px;
    text-align: center;
}

.bt-upload-progress-bar {
    height: 6px;
    background: #dcdcde;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.bt-upload-progress-fill {
    height: 100%;
    width: 0;
    background: #2271b1;
    border-radius: 3px;
    transition: width 0.3s;
    animation: bt-progress-pulse 1.5s ease-in-out infinite;
}

@keyframes bt-progress-pulse {
    0%, 100% { width: 30%; }
    50% { width: 80%; }
}

.bt-upload-result {
    margin-top: 16px;
    padding: 12px 16px;
    background: #edfaef;
    border: 1px solid #00a32a;
    border-radius: 4px;
    color: #00a32a;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bt-upload-result .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* =========================================================================
   FORM ELEMENTS
   ====================================================================== */

.bt-form-group {
    margin-bottom: 16px;
}

.bt-form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 13px;
}

.bt-form-group label .required {
    color: #d63638;
}

.bt-form-group input[type="checkbox"] + *,
.bt-form-group label input[type="checkbox"] {
    font-weight: 400;
}

/* =========================================================================
   PREVIEW TABLE
   ====================================================================== */

.bt-preview-wrapper {
    max-height: 300px;
    overflow: auto;
    margin-bottom: 20px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
}

.bt-preview-wrapper .wp-list-table {
    margin: 0;
}

.bt-preview-wrapper .wp-list-table td,
.bt-preview-wrapper .wp-list-table th {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    padding: 6px 10px;
}

/* =========================================================================
   COLUMN MAPPING
   ====================================================================== */

.bt-column-mapping {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.bt-mapping-item {
    background: #f6f7f7;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #dcdcde;
}

.bt-mapping-item-label {
    font-size: 12px;
    color: #646970;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bt-mapping-item-preview {
    font-size: 11px;
    color: #8c8f94;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bt-mapping-item select {
    width: 100%;
}

/* =========================================================================
   SHORTCODE DISPLAY
   ====================================================================== */

.bt-shortcode-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f6f7f7;
    padding: 10px 14px;
    border-radius: 4px;
    border: 1px solid #dcdcde;
    margin: 8px 0;
}

.bt-shortcode-display code {
    flex: 1;
    font-size: 13px;
    background: none;
    padding: 0;
    word-break: break-all;
}

/* =========================================================================
   SUCCESS MESSAGE
   ====================================================================== */

.bt-success-message {
    text-align: center;
    padding: 20px 0;
}

.bt-success-icon {
    font-size: 64px !important;
    width: 64px !important;
    height: 64px !important;
    color: #00a32a;
}

.bt-success-message h3 {
    font-size: 18px;
    margin: 16px 0 8px;
}

.bt-shortcode-options {
    text-align: left;
    margin-top: 24px;
}

.bt-shortcode-options h4 {
    margin-bottom: 8px;
}

/* =========================================================================
   STEP ACTIONS
   ====================================================================== */

.bt-step-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f1;
}

.bt-step-actions .button .dashicons {
    vertical-align: middle;
    margin-right: 4px;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* =========================================================================
   EDIT MODAL EXTRAS
   ====================================================================== */

#bt-edit-modal .bt-new-modal-body hr {
    border: none;
    border-top: 1px solid #f0f0f1;
    margin: 20px 0;
}

#bt-reupload-result {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
}

#bt-reupload-result.bt-success {
    background: #edfaef;
    border: 1px solid #00a32a;
    color: #00a32a;
}

#bt-reupload-result.bt-error {
    background: #fcf0f1;
    border: 1px solid #d63638;
    color: #d63638;
}

/* =========================================================================
   TOAST NOTIFICATION
   ====================================================================== */

.bt-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1d2327;
    color: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 100200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: bt-toast-in 0.3s ease-out;
}

.bt-toast.bt-toast-out {
    animation: bt-toast-out 0.3s ease-in forwards;
}

@keyframes bt-toast-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes bt-toast-out {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* =========================================================================
   RESPONSIVE
   ====================================================================== */

@media screen and (max-width: 782px) {
    .bt-admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .bt-tables-grid {
        grid-template-columns: 1fr;
    }

    .bt-new-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .bt-steps {
        gap: 12px;
        flex-wrap: wrap;
    }

    .bt-column-mapping {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   RANGE SLIDER
   ====================================================================== */

.bt-range-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 6px;
}

.bt-range-wrapper input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #d0d5dd;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.bt-range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2271b1;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.bt-range-wrapper input[type="range"]::-webkit-slider-thumb:hover {
    background: #135e96;
    box-shadow: 0 2px 8px rgba(34,113,177,0.3);
}

.bt-range-wrapper input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2271b1;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.bt-range-wrapper output {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    font-size: 16px;
    font-weight: 700;
    color: #2271b1;
    background: #f0f6fc;
    border: 2px solid #2271b1;
    border-radius: 8px;
}
