/**
 * BW AI Schema Pro Admin Styles
 */

/* Reset box-sizing for our plugin */
.bw-schema-admin-wrap *,
.bw-schema-admin-wrap *::before,
.bw-schema-admin-wrap *::after {
    box-sizing: border-box;
}

/* General Admin Styles */
.bw-schema-admin-wrap {
    margin: 20px 20px 20px 0;
    max-width: 1200px;
    /* Ensure proper width calculation */
    width: 100%;
    box-sizing: border-box;
}

/* Fix for WordPress admin container */
.wrap .bw-schema-admin-wrap {
    margin-left: 0;
}

/* Ensure all children use border-box */
.bw-schema-admin-wrap * {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.bw-schema-admin-wrap h1 {
    font-size: 28px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.bw-schema-admin-wrap h1 .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

/* Dashboard Header */
.bw-schema-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.bw-schema-header-actions .button {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Dashboard Stats Grid */
.bw-schema-stats-grid {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: -10px;
    margin-bottom: 20px;
}

.bw-schema-stats-grid::after {
    content: "";
    display: table;
    clear: both;
}

.bw-schema-stat-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    transition: all 0.3s ease;
    -webkit-box-flex: 1;
    -ms-flex: 1 1 calc(25% - 20px);
    flex: 1 1 calc(25% - 20px);
    margin: 10px;
    min-width: 200px;
    box-sizing: border-box;
}

.bw-schema-stat-card:hover {
    border-color: #2271b1;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.1);
}

.bw-schema-stat-icon {
    background: #f0f6fc;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    margin-right: 15px;
}

.bw-schema-stat-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #2271b1;
}

.bw-schema-stat-content {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 0; /* Prevent flex items from overflowing */
}

.bw-schema-stat-number {
    font-size: 28px;
    font-weight: 600;
    color: #1d2327;
    display: block;
    line-height: 1;
}

.bw-schema-stat-label {
    color: #666;
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

/* Dashboard Cards Grid - Simple Flexbox Layout */
.bw-schema-dashboard-grid {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: -10px;
    margin-bottom: 20px;
}

.bw-schema-dashboard-grid::after {
    content: "";
    display: table;
    clear: both;
}

.bw-schema-dashboard-grid .bw-schema-card {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 calc(33.333% - 20px);
    flex: 1 1 calc(33.333% - 20px);
    margin: 10px;
    min-width: 280px;
    max-width: 400px;
    box-sizing: border-box;
}

/* Ensure cards fill available space properly */
.bw-schema-dashboard-grid {
    justify-content: flex-start;
}

@media (min-width: 1400px) {
    .bw-schema-dashboard-grid .bw-schema-card {
        max-width: calc(33.333% - 20px);
    }
}

/* Force 2 columns on medium screens */
@media (max-width: 1200px) and (min-width: 783px) {
    .bw-schema-dashboard-grid .bw-schema-card {
        -ms-flex: 1 1 calc(50% - 20px);
        flex: 1 1 calc(50% - 20px);
    }
}

.bw-schema-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.bw-schema-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.bw-schema-card-header {
    padding: 20px 20px 0;
    border-bottom: 1px solid #f0f0f0;
}

.bw-schema-card-header h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bw-schema-card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.bw-schema-card-footer {
    padding: 15px 20px;
    border-top: 1px solid #f0f0f0;
    margin-top: auto;
}

.bw-schema-card .dashicons {
    color: #2271b1;
}

/* Quick Actions */
.bw-schema-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.bw-schema-action-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: 5px;
    text-decoration: none;
    color: #1d2327;
    transition: all 0.2s ease;
}

.bw-schema-action-item:hover {
    background: #e7f1ff;
    color: #135e96;
}

.bw-schema-action-item .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Feature List */
.bw-schema-feature-list {
    margin-top: 15px;
}

.bw-schema-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: #50575e;
}

.bw-schema-feature-item .dashicons {
    color: #00a32a;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Progress Bar */
.bw-schema-progress-container {
    margin: 20px 0;
}

.bw-schema-progress-bar {
    background: #f0f0f0;
    border-radius: 10px;
    height: 30px;
    overflow: hidden;
    position: relative;
}

.bw-schema-progress-fill {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.5s ease;
    min-width: 50px;
}

.bw-schema-progress-text {
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.bw-schema-progress-label {
    text-align: center;
    margin-top: 10px;
    color: #666;
    font-size: 13px;
}

/* Tips List */
.bw-schema-tips-list {
    margin-top: 15px;
}

.bw-schema-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.bw-schema-tip:last-child {
    border-bottom: none;
}

.bw-schema-tip-number {
    background: #2271b1;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Resources Grid */
.bw-schema-bottom-section {
    margin-top: 30px;
}

.bw-schema-card-resources .bw-schema-card-content {
    padding: 0;
}

.bw-schema-resources-grid {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

/* Use grid if supported */
@supports (display: grid) {
    .bw-schema-resources-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0;
    }
}

.bw-schema-resource-item {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    text-align: center;
    padding: 25px 20px;
    text-decoration: none;
    color: #1d2327;
    border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    -webkit-box-flex: 1;
    -ms-flex: 1 1 200px;
    flex: 1 1 200px;
    min-width: 200px;
}

.bw-schema-resource-item:hover {
    background: #f0f6fc;
}

.bw-schema-resource-item .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #2271b1;
    margin-bottom: 10px;
}

.bw-schema-resource-item h4 {
    margin: 10px 0 5px 0;
    font-size: 15px;
    font-weight: 600;
}

.bw-schema-resource-item p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

/* Stats */
.bw-schema-stats {
    display: flex;
    gap: 30px;
    margin: 20px 0;
}

.bw-schema-stat {
    background: #f0f6fc;
    padding: 15px 20px;
    border-radius: 5px;
    flex: 1;
    text-align: center;
}

.bw-schema-stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #2271b1;
    display: block;
}

.bw-schema-stat-label {
    color: #666;
    font-size: 14px;
}

/* Forms */
.bw-schema-form {
    background: #fff;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-top: 20px;
}

.bw-schema-form-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.bw-schema-form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.bw-schema-form-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 20px;
}

.bw-schema-form-row {
    margin-bottom: 20px;
}

.bw-schema-form-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #1d2327;
}

.bw-schema-form-row .description {
    margin-top: 5px;
    color: #666;
    font-size: 13px;
    font-style: italic;
}

.bw-schema-form-row input[type="text"],
.bw-schema-form-row input[type="email"],
.bw-schema-form-row input[type="url"],
.bw-schema-form-row input[type="tel"],
.bw-schema-form-row textarea,
.bw-schema-form-row select {
    width: 100%;
    max-width: 600px;
}

/* Multiple Fields */
.bw-schema-repeater {
    max-width: 600px;
}

.bw-schema-repeater-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.bw-schema-repeater-item input {
    flex: 1;
}

.bw-schema-repeater-item button {
    flex-shrink: 0;
}

.bw-schema-add-field {
    margin-top: 10px;
}

/* Schema Type Selector */
.bw-schema-type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.bw-schema-type-card {
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.bw-schema-type-card:hover {
    border-color: #2271b1;
    background: #f0f6fc;
}

.bw-schema-type-card.selected {
    border-color: #2271b1;
    background: #e7f1ff;
}

.bw-schema-type-card .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    margin-bottom: 10px;
    color: #2271b1;
}

.bw-schema-type-card h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

.bw-schema-type-card p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

/* Tabs */
.bw-schema-tabs {
    margin: 20px 0;
}

.bw-schema-tab-nav {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 20px;
}

.bw-schema-tab-nav a {
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
}

.bw-schema-tab-nav a:hover {
    color: #2271b1;
}

.bw-schema-tab-nav a.active {
    color: #2271b1;
    border-bottom-color: #2271b1;
}

.bw-schema-tab-content {
    display: none;
}

.bw-schema-tab-content.active {
    display: block;
}

/* Preview */
.bw-schema-preview {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    margin: 20px 0;
}

.bw-schema-preview pre {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 15px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
}

/* Author Profiles Table */
.bw-schema-authors-table {
    width: 100%;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 20px;
}

.bw-schema-authors-table th {
    background: #f5f5f5;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
}

.bw-schema-authors-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.bw-schema-authors-table tr:last-child td {
    border-bottom: none;
}

.bw-schema-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
}

/* AI Tools */
.bw-schema-ai-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.bw-schema-ai-tool {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
}

.bw-schema-ai-tool h3 {
    margin-top: 0;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bw-schema-ai-tool .dashicons {
    color: #00a32a;
}

/* Buttons */
.bw-schema-button-group {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.bw-schema-button-primary {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.bw-schema-button-primary:hover {
    background: #135e96;
}

/* Success/Error Messages */
.bw-schema-notice {
    padding: 12px;
    margin: 20px 0;
    border-radius: 4px;
    border-left: 4px solid;
}

.bw-schema-notice.success {
    background: #e7f5e7;
    border-left-color: #00a32a;
    color: #00a32a;
}

.bw-schema-notice.error {
    background: #fce4e4;
    border-left-color: #d63638;
    color: #d63638;
}

/* Loading Spinner */
.bw-schema-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: bw-schema-spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes bw-schema-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Schema Conflict Manager */
.bw-schema-conflict-manager {
    margin-top: 20px;
}

.bw-schema-conflict-manager table {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.bw-schema-conflict-manager th {
    background: #f5f5f5;
    font-weight: 600;
    padding: 12px;
}

.bw-schema-conflict-manager td {
    padding: 12px;
    vertical-align: middle;
}

.bw-schema-conflict-manager .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 5px;
}

/* Tooltips */
.bw-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    margin-left: 5px;
}

.bw-tooltip .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #666;
    vertical-align: middle;
}

.bw-tooltip:hover .dashicons {
    color: #0073aa;
}

.bw-tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10000;
    transition: opacity 0.3s, visibility 0.3s;
    max-width: 300px;
    white-space: normal;
}

.bw-tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.bw-tooltip:hover .bw-tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Help text */
.bw-help-text {
    color: #666;
    font-style: italic;
    font-size: 13px;
    margin-top: 5px;
    line-height: 1.5;
}

.bw-help-text code {
    background: #f1f1f1;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 12px;
}

/* Schema Preview */
.bw-schema-preview {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

/* Fallback for very old browsers */
.bw-schema-dashboard-grid:after,
.bw-schema-stats-grid:after,
.bw-schema-resources-grid:after {
    content: "";
    display: table;
    clear: both;
}

/* Float fallback for ancient browsers */
.no-flexbox .bw-schema-card,
.no-flexbox .bw-schema-stat-card {
    float: left;
    width: calc(33.333% - 20px);
    margin: 0 10px 20px 10px;
}

.no-flexbox .bw-schema-resource-item {
    float: left;
    width: 25%;
}

/* Layout ready state */
.bw-schema-admin-wrap.layout-ready {
    opacity: 1;
}

/* Clear floats */
.bw-schema-dashboard-grid:before,
.bw-schema-dashboard-grid:after,
.bw-schema-stats-grid:before,
.bw-schema-stats-grid:after {
    content: " ";
    display: table;
}

.bw-schema-dashboard-grid:after,
.bw-schema-stats-grid:after {
    clear: both;
}

/* IE 10-11 specific fixes */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .bw-schema-dashboard-grid,
    .bw-schema-stats-grid {
        display: block;
    }
    
    .bw-schema-card,
    .bw-schema-stat-card {
        display: inline-block;
        vertical-align: top;
    }
}

/* Responsive */
@media screen and (max-width: 782px) {
    .bw-schema-dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .bw-schema-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .bw-schema-type-selector {
        grid-template-columns: 1fr;
    }
    
    .bw-schema-resources-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .bw-schema-quick-actions {
        grid-template-columns: 1fr;
    }
}