/* Pic-Time Connect Admin Styles */

/* ===== HEADER AND BRANDING ===== */
.ptbsb-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px 0;
    border-bottom: 1px solid #ddd;
    max-width: 1320px;
    margin-left: 0;
}

.ptbsb-logo {
    width: 60px;
    height: 40px;
    margin-right: 15px;
}

.ptbsb-title {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.ptbsb-version {
    color: #666;
    font-size: 14px;
    font-weight: normal;
}

/* ===== BRAND CARD - FULL WIDTH BANNER ===== */
.ptbsb-brand-card {
    background: linear-gradient(325deg, #e8f5ff 0%, #d3e1ed85 100%);
    border-left: 4px solid #2271b1;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    .ptbsb-brand-card {
        max-width: 1320px; /* 1300px + 20px gap */
    }
}

.ptbsb-brand-header {
    margin-bottom: 12px;
}

.ptbsb-brand-title {
    margin: 0 0 8px 0;
    font-size: 19px;
    color: #2271b1;
    font-weight: 600;
}

.ptbsb-brand-description {
    margin: 0;
    color: #666;
    line-height: 1.6;
}

/* ===== UPDATE NOTICES ===== */
.ptbsb-update-notice {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
}

/* ===== MODAL STYLES (Stronger WordPress Override) ===== */
body.wp-admin div#ptbsb-version-history-modal,
body.wp-admin div#ptbsb-selective-mode-modal {
    display: none !important;
    position: fixed !important;
    z-index: 999999 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    overflow: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force show when JavaScript adds style */
body.wp-admin div#ptbsb-version-history-modal[style*="display: block"],
body.wp-admin div#ptbsb-selective-mode-modal[style*="display: block"] {
    display: block !important;
}

body.wp-admin div.ptbsb-modal-content {
    background-color: #ffffff !important;
    margin: 5% auto !important;
    padding: 30px !important;
    border: none !important;
    width: 80% !important;
    max-width: 700px !important;
    border-radius: 6px !important;
    position: relative !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    display: block !important;
}

body.wp-admin span.ptbsb-close {
    color: #999999 !important;
    position: absolute !important;
    right: 20px !important;
    top: 20px !important;
    font-size: 30px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    z-index: 999999 !important;
    line-height: 1 !important;
    width: 30px !important;
    height: 30px !important;
    text-align: center !important;
    display: block !important;
}

body.wp-admin span.ptbsb-close:hover,
body.wp-admin span.ptbsb-close:focus {
    color: #333333 !important;
    background-color: #f0f0f0 !important;
    border-radius: 50% !important;
}

body.wp-admin div.ptbsb-modal h2 {
    color: #2271b1 !important;
    margin-top: 0 !important;
    margin-right: 50px !important;
    font-size: 22px !important;
    padding-right: 20px !important;
}

body.wp-admin div.ptbsb-modal h3 {
    color: #444444 !important;
    border-bottom: 1px solid #dddddd !important;
    padding-bottom: 8px !important;
    margin-top: 25px !important;
    margin-bottom: 15px !important;
}

body.wp-admin div.ptbsb-modal ol,
body.wp-admin div.ptbsb-modal ul {
    margin: 15px 0 !important;
    padding-left: 25px !important;
}

body.wp-admin div.ptbsb-modal li {
    margin-bottom: 8px !important;
    line-height: 1.5 !important;
}

body.wp-admin div.ptbsb-modal pre {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 4px !important;
    padding: 15px !important;
    overflow-x: auto !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    margin: 15px 0 !important;
    font-family: 'Courier New', Courier, monospace !important;
}

body.wp-admin div.ptbsb-modal p {
    margin: 10px 0 !important;
    line-height: 1.6 !important;
}

body.wp-admin div.ptbsb-modal code {
    background: #f1f3f4 !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 13px !important;
}

/* ===== BUTTONS AND FORMS ===== */
.ptbsb-button-primary {
    background: #0073aa;
    border: 1px solid #0073aa;
    color: white;
    padding: 8px 16px;
    border-radius: 3px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.ptbsb-button-primary:hover {
    background: #005a87;
    border-color: #005a87;
    color: white;
}

.ptbsb-button-secondary {
    background: #f7f7f7;
    border: 1px solid #ccc;
    color: #555;
    padding: 8px 16px;
    border-radius: 3px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.ptbsb-button-secondary:hover {
    background: #fafafa;
    border-color: #999;
    color: #222;
}

/* ===== FORM IMPROVEMENTS ===== */
.form-table th {
    font-weight: 600;
    color: #2c3e50;
    padding: 15px 10px 15px 0;
}

.form-table td {
    padding: 15px 10px;
}

/* ===== STATUS INDICATORS ===== */
.ptbsb-status-active {
    color: #46b450;
    font-weight: 600;
}

.ptbsb-status-inactive {
    color: #dc3232;
    font-weight: 600;
}

.ptbsb-status-warning {
    color: #ffb900;
    font-weight: 600;
}

/* ===== CARD STYLING ===== */
.card {
    max-width: none !important;
    width: 100%;
    box-sizing: border-box !important;
}

.card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    color: #2c3e50;
}

/* ===== INFO BOXES ===== */
.ptbsb-info-box {
    background: #e7f3ff;
    border-left: 4px solid #0073aa;
    padding: 12px 16px;
    margin: 15px 0;
}

.ptbsb-warning-box {
    background: #fff8e1;
    border-left: 4px solid #ffb900;
    padding: 12px 16px;
    margin: 15px 0;
}

.ptbsb-success-box {
    background: #ecf4ea;
    border-left: 4px solid #46b450;
    padding: 12px 16px;
    margin: 15px 0;
}

/* ===== CODE FORMATTING ===== */
code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 13px;
}

pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid #ddd;
}

/* ===== SYSTEM INFO TABLE ===== */
.widefat tbody tr td:first-child {
    font-weight: 600;
    width: 30%;
}

/* ===== LOG DISPLAY ===== */
.ptbsb-log-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ===== MAINTENANCE TOOLS ===== */
.ptbsb-maintenance-section {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 20px;
    margin: 15px 0;
}

.ptbsb-maintenance-section h3 {
    margin-top: 0;
    color: #2c3e50;
}

/* ===== SCAN STATUS CARD - HORIZONTAL METRICS LAYOUT ===== */
.ptbsb-scan-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 20px 0;
}

.ptbsb-scan-metric {
    text-align: center;
}

.ptbsb-scan-metric-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
    display: block;
}

.ptbsb-scan-metric-value.status-warning {
    color: #ffb900;
}

.ptbsb-scan-metric-value.status-success {
    color: #46b450;
}

.ptbsb-scan-metric-value.status-inactive {
    color: #666;
}

.ptbsb-scan-metric-label {
    font-size: 13px;
    color: #666;
    display: block;
}

/* Second row of metrics */
.ptbsb-scan-metrics-secondary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 15px 0 20px 0;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.ptbsb-scan-metric-secondary {
    text-align: center;
}

.ptbsb-scan-metric-time {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
    display: block;
}

.ptbsb-scan-metric-time.status-success {
    color: #46b450;
}

.ptbsb-scan-metric-time.status-warning {
    color: #ffb900;
}

.ptbsb-scan-metric-sublabel {
    font-size: 12px;
    color: #666;
    display: block;
}

/* Scan button and description */
.ptbsb-scan-action {
    text-align: center;
    margin-top: 15px;
}

.ptbsb-scan-description {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-top: 8px;
}

/* ===== TWO-COLUMN LAYOUT WITH MUCH WIDER LEFT COLUMN ===== */
@media (min-width: 1024px) {
    .ptbsb-admin-layout {
        display: grid;
        grid-template-columns: calc(65% - 50px) calc(35% + 50px);
        gap: 20px;
        margin-top: 20px;
        max-width: 1300px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .ptbsb-column-left,
    .ptbsb-column-right {
        display: flex;
        flex-direction: column;
        gap: 20px;
        box-sizing: border-box;
    }
    
    /* Remove default margins since grid handles spacing */
    .ptbsb-admin-layout .card {
        margin: 0;
        box-sizing: border-box;
    }
}

@media (max-width: 1023px) {
    .ptbsb-admin-layout {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    /* Set explicit order for mobile view */
    .ptbsb-column-left,
    .ptbsb-column-right {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    /* Card ordering */
    .ptbsb-column-right > .card:nth-child(1) { /* Scan Status */
        order: 1;
    }
    
    .ptbsb-column-right > .card:nth-child(2) { /* SEO Compat */
        order: 2;
    }
    
    .ptbsb-column-left > .card:nth-child(1) { /* Sitemap Info */
        order: 3;
    }
    
    .ptbsb-column-left > .card:nth-child(2) { /* Plugin Settings */
        order: 4;
    }
    
    .ptbsb-column-right > .card:nth-child(4) { /* Maintenance */
        order: 5;
    }
    
    .ptbsb-column-right > .card:nth-child(3) { /* System Info */
        order: 6;
    }
    
    /* Merge columns visually */
    .ptbsb-admin-layout {
        display: block;
    }
    
    .ptbsb-column-left > *,
    .ptbsb-column-right > * {
        margin-bottom: 20px;
    }
}
/* On smaller screens, stack everything vertically with proper order */
@media (max-width: 1023px) {
    .ptbsb-admin-layout {
        display: grid;
        grid-template-columns: 1fr;
        grid-auto-flow: dense;
        gap: 20px;
    }
    
    /* Make both column divs part of the same grid */
    .ptbsb-column-left,
    .ptbsb-column-right {
        display: contents; /* THIS IS THE KEY - makes children become grid items */
    }
    
    /* Now all .card elements are direct grid items, so we can position them */
    /* Order: SCAN (R1) → SEO (R2) → SITEMAP (L1) → SETTINGS (L2) → MAINTENANCE (R4) → SYSTEM (R3) */
    
    /* Right column cards */
    .ptbsb-column-right > .card:nth-child(1) {
        order: 1; /* Scan Status */
    }
    
    .ptbsb-column-right > .card:nth-child(2) {
        order: 2; /* SEO Compatibility */
    }
    
    .ptbsb-column-right > .card:nth-child(3) {
        order: 6; /* System Info */
    }
    
    .ptbsb-column-right > .card:nth-child(4) {
        order: 5; /* Maintenance */
    }
    
    /* Left column cards */
    .ptbsb-column-left > .card:nth-child(1) {
        order: 3; /* Sitemap Info */
    }
    
    .ptbsb-column-left > .card:nth-child(2) {
        order: 4; /* Plugin Settings */
    }
    
    /* Adjust grid for scan metrics */
    .ptbsb-scan-metrics,
    .ptbsb-scan-metrics-secondary {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .ptbsb-scan-metric,
    .ptbsb-scan-metric-secondary {
        padding: 10px;
        background: #f9f9f9;
        border-radius: 4px;
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 782px) {
    .ptbsb-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ptbsb-logo {
        margin-bottom: 10px;
        margin-right: 0;
    }
    
    .ptbsb-modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .ptbsb-brand-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ptbsb-brand-logo {
        margin-bottom: 10px;
        margin-right: 0;
    }
    
    .form-table th,
    .form-table td {
        display: block;
        width: 100%;
        padding: 10px 0;
    }
    
    .form-table th {
        border-bottom: none;
        padding-bottom: 5px;
    }
}

@media (min-width: 783px) and (max-width: 1023px) {
    .ptbsb-scan-metrics,
    .ptbsb-scan-metrics-secondary {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    .ptbsb-scan-metric-value {
        font-size: 28px;
    }
}

/* ===== CONSISTENT SPACING FOR ALL CARDS ===== */
.wrap > .notice {
    margin-bottom: 20px;
}

/* Success/Notice messages below header */
.wrap > .notice {
    margin-bottom: 20px;
}

@media (min-width: 1024px) {
    .wrap > .notice {
        max-width: 1320px;
        margin-left: 0;
    }
}

.wrap > .card:first-of-type,
.ptbsb-brand-card + .card {
    margin-top: 20px;
}

/* Ensure all cards in the layout have consistent spacing */
.ptbsb-admin-layout .card,
.ptbsb-column-left > .card,
.ptbsb-column-right > .card {
    margin-bottom: 0;
}

/* ===== ADMIN NOTICES INTEGRATION ===== */
.notice.ptbsb-notice {
    border-left-width: 4px;
    border-left-style: solid;
}

.notice.ptbsb-notice.notice-info {
    border-left-color: #0073aa;
}

.notice.ptbsb-notice.notice-warning {
    border-left-color: #ffb900;
}

.notice.ptbsb-notice.notice-success {
    border-left-color: #46b450;
}

/* ===== HELP TEXT STYLING ===== */
.description {
    font-style: italic;
    color: #666;
}

.description strong {
    font-weight: 600;
    color: #333;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
.ptbsb-modal:focus-within .ptbsb-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.button:focus,
.button-primary:focus,
.button-secondary:focus {
    box-shadow: 0 0 0 2px #0073aa;
    outline: none;
}

/* ===== LOADING STATES ===== */
.ptbsb-loading {
    opacity: 0.6;
    pointer-events: none;
}

.ptbsb-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: ptbsb-spin 1s linear infinite;
}

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

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .ptbsb-brand-card {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        color: #ecf0f1;
    }
    
    .ptbsb-brand-title {
        color: #3498db;
    }
    
    .ptbsb-modal-content {
        background-color: #2c3e50;
        color: #ecf0f1;
        border-color: #34495e;
    }
    
    .ptbsb-modal h2 {
        color: #3498db;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .ptbsb-modal,
    .button,
    .notice {
        display: none !important;
    }
    
    .ptbsb-header {
        border-bottom: 2px solid #000;
    }
    
    .card {
        border: 1px solid #000;
        margin: 10px 0;
        break-inside: avoid;
    }
}

/* ===== MODAL QUICK REFERENCE TABLE ===== */
.ptbsb-modal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.ptbsb-modal-table thead tr {
    background: #f0f0f1;
}

.ptbsb-modal-table th,
.ptbsb-modal-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #ddd;
}

/* ===== CODE EXAMPLES IN MODALS ===== */
.ptbsb-code-example {
    background-color: #f5f5f5;
    padding: 10px;
    overflow: auto;
    font-size: 12px;
}

/* ===== CARD SPACING ===== */
.ptbsb-card-section {
    margin-top: 20px;
}

/* ===== INLINE FORMS ===== */
.ptbsb-inline-form {
    display: inline;
}

/* ===== DESCRIPTION INDENTATION ===== */
.ptbsb-description-indent {
    margin-left: 25px;
    margin-top: 5px;
}

/* ===== LOG TEXTAREA ===== */
.ptbsb-log-textarea {
    width: 100%;
    height: 150px;
    font-family: monospace;
    font-size: 11px;
}

/* Show loading state when button is clicked - CSS only */
#ptbsb-scan-button:active,
#ptbsb-scan-button:focus {
    opacity: 0.6;
    cursor: wait;
}

#ptbsb-scan-button:active::before,
#ptbsb-scan-button:focus::before {
    content: "⏳ ";
}

/* Modal Styles */
.ptbsb-modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.ptbsb-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.ptbsb-close {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.ptbsb-close:hover,
.ptbsb-close:focus {
    color: #000;
    text-decoration: none;
}

.ptbsb-modal h2 {
    margin-top: 0;
    padding-right: 40px;
}

.ptbsb-modal h3 {
    color: #2271b1;
    margin-top: 25px;
}

.ptbsb-modal pre {
    background: #f5f5f5;
    padding: 12px;
    border-left: 3px solid #2271b1;
    overflow-x: auto;
    font-size: 13px;
}

.ptbsb-modal ol, .ptbsb-modal ul {
    line-height: 1.8;
}

/* ===== SCAN ISSUES MODAL SPECIFIC STYLES ===== */
body.wp-admin div#ptbsb-scan-issues-modal {
    display: none !important;
    position: fixed !important;
    z-index: 999999 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    overflow: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force show when JavaScript adds style */
body.wp-admin div#ptbsb-scan-issues-modal[style*="display: block"],
body.wp-admin div#ptbsb-scan-issues-modal[style*="display:block"] {
    display: block !important;
}

/* Scan Issues Modal Close Button */
body.wp-admin span.ptbsb-modal-close {
    color: #999999 !important;
    position: absolute !important;
    right: 20px !important;
    top: 20px !important;
    font-size: 30px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    z-index: 999999 !important;
    line-height: 1 !important;
    width: 30px !important;
    height: 30px !important;
    text-align: center !important;
    display: block !important;
}

body.wp-admin span.ptbsb-modal-close:hover,
body.wp-admin span.ptbsb-modal-close:focus {
    color: #333333 !important;
    background-color: #f0f0f0 !important;
    border-radius: 50% !important;
}

/* Scan Issues Modal Content - Wider for table */
body.wp-admin div#ptbsb-scan-issues-modal .ptbsb-modal-content {
    max-width: 900px !important;
}

/* Scan Issues Table Styling */
body.wp-admin div#ptbsb-scan-issues-modal table.widefat {
    margin-top: 15px !important;
    border: 1px solid #ddd !important;
}

body.wp-admin div#ptbsb-scan-issues-modal table.widefat thead tr {
    background: #f9f9f9 !important;
}

body.wp-admin div#ptbsb-scan-issues-modal table.widefat th {
    font-weight: 600 !important;
    padding: 12px !important;
    border-bottom: 2px solid #ddd !important;
}

body.wp-admin div#ptbsb-scan-issues-modal table.widefat td {
    padding: 12px !important;
    border-bottom: 1px solid #eee !important;
}

body.wp-admin div#ptbsb-scan-issues-modal table.widefat tbody tr:hover {
    background: #f5f5f5 !important;
}

/* Responsive table for scan issues modal */
@media (max-width: 900px) {
    body.wp-admin div#ptbsb-scan-issues-modal .ptbsb-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px !important;
    }
    
    body.wp-admin div#ptbsb-scan-issues-modal table.widefat {
        font-size: 12px !important;
    }
    
    body.wp-admin div#ptbsb-scan-issues-modal table.widefat th,
    body.wp-admin div#ptbsb-scan-issues-modal table.widefat td {
        padding: 8px !important;
    }
}