/* ======================================================
   Cloudflare R2 Storage Manager – Admin UI
   Scoped Design System (Lite / Pro / Ultimate)
   ====================================================== */

.cr2sm-admin {
    /* ---------- Design Tokens ---------- */
    /* Cloudflare Brand Colors */
    --cr2sm-primary: #F38020;
    /* Cloudflare Orange */
    --cr2sm-primary-hover: #c4620e;

    --cr2sm-surface: #ffffff;
    --cr2sm-bg: #f0f0f1;

    --cr2sm-text-main: #1d2327;
    --cr2sm-text-muted: #646970;

    --cr2sm-border: #c3c4c7;
    --cr2sm-border-focus: #2271b1;

    --cr2sm-radius: 4px;
    /* Standard WP radius */

    --cr2sm-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* ======================================================
   Reset & Scope
   ====================================================== */

/* Outer Wrapper adjustments */
.cr2sm-admin {
    margin-right: 20px;
    max-width: 100%;
    color: var(--cr2sm-text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.cr2sm-admin * {
    box-sizing: border-box;
}

.cr2sm-admin h1 {
    padding: 9px 0 4px;
    font-size: 23px;
    font-weight: 400;
    margin: 0;
    color: #1d2327;
}

.cr2sm-admin h1 .cr2sm-h1-icon {
    width: 20px;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 3px;
}

.cr2sm-admin h1 .cr2sm-h1-icon-dash {
    font-size: 24px;
    width: 24px;
    height: 24px;
    line-height: 24px;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 3px;
    display: inline-block;
    color: var(--cr2sm-primary);
}


.cr2sm-admin h2 {
    font-size: 14px;
    margin: 0 0 10px;
    font-weight: 600;
    color: #1d2327;
}

.cr2sm-admin h3 {
    font-size: 13px;
    margin: 0 0 8px;
    font-weight: 600;
    color: #1d2327;
}

/* ======================================================
   Common Components
   ====================================================== */

/* Cards (Metabox style) */
.cr2sm-admin .card {
    background: var(--cr2sm-surface);
    border: 1px solid var(--cr2sm-border);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
    margin-top: 20px;
    padding: 0;
    max-width: 100%;
    /* Ensure cards stretch to fill grid cells */
    height: 100%;
    display: flex;
    flex-direction: column;
}

.cr2sm-admin .card .content-pad {
    padding: 15px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Utility Texts */
.cr2sm-admin .sub-description {
    color: var(--cr2sm-text-muted);
    font-size: 13px;
    margin: 0 0 15px;
    line-height: 1.5;
}

/* Buttons (Strict WP Standard) */
.cr2sm-admin .button,
.cr2sm-admin .button-primary,
.cr2sm-admin .button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    line-height: 2 !important;
    padding: 0 12px;
    font-size: 13px !important;
    border-radius: 3px;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    font-weight: 400;
}

/* Primary Button color override within scope */
.cr2sm-admin .button-primary {
    background: var(--cr2sm-primary) !important;
    border-color: var(--cr2sm-primary) !important;
    color: #fff !important;
    transition: all 0.2s ease;
}

.cr2sm-admin .button-primary:hover,
.cr2sm-admin .button-primary:focus {
    background: var(--cr2sm-primary-hover) !important;
    border-color: var(--cr2sm-primary-hover) !important;
    color: #fff !important;
}

/* ======================================================
   Dashboard Grid Layout
   ====================================================== */

.cr2sm-dashboard-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.cr2sm-dashboard-top {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: stretch;
}

/* Ensure wide cards stay wide */
.cr2sm-admin .card {
    width: 100%;
}

.cr2sm-admin .column-key {
    width: auto !important;
}

.cr2sm-admin .column-size {
    white-space: nowrap;
}

.cr2sm-admin .regular-text {
    width: 100%;
    max-width: 100%;
}

/* Responsive */
@media screen and (max-width: 960px) {
    .cr2sm-dashboard-top {
        grid-template-columns: 1fr;
        /* Stack vertically */
    }
}

/* ======================================================
   Dashboard: Welcome Card
   ====================================================== */

.cr2sm-dashboard-welcome .cr2sm-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: auto;
    /* Push to bottom */
    padding-top: 20px;
    border-top: 1px solid #f0f0f1;
}

@media screen and (max-width: 782px) {
    .cr2sm-dashboard-welcome .cr2sm-action-grid {
        grid-template-columns: 1fr;
    }
}

.cr2sm-action-card {
    background: #fcfcfc;
    border: 1px solid #f0f0f1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cr2sm-action-card h3 {
    margin-top: 0;
}

.cr2sm-action-card p {
    margin: 5px 0 15px;
    color: var(--cr2sm-text-muted);
}

.cr2sm-flex-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ======================================================
   Dashboard: Upsell Card
   ====================================================== */

.cr2sm-dashboard-upsell .content-pad {
    align-items: flex-start;
    justify-content: center;
}

/* ======================================================
   Tables (Comparison & Files)
   ====================================================== */

.cr2sm-admin table.wp-list-table {
    border: 1px solid #c3c4c7;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}

.cr2sm-admin table.wp-list-table th {
    font-weight: 600;
}

/* Helper to limit max width on huge screens */
.cr2sm-max-width {
    max-width: 1400px;
}

/* ======================================================
   Upload Results UI
   ====================================================== */
.cr2sm-upload-result {
    padding: 15px 10px;
}

.cr2sm-upload-result h2 {
    margin: 0 0 10px;
    font-size: 18px;
}

.cr2sm-upload-box {
    background: #fff;
    padding: 15px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 600px;
}

.cr2sm-upload-box label {
    font-weight: 600;
    margin-bottom: 4px;
}

.cr2sm-upload-box input.regular-text {
    width: 100%;
}

.cr2sm-upload-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.cr2sm-copy-feedback {
    display: none;
    color: #46b450;
    font-weight: 600;
}

/* =========================================
   File View Table Layout Optimization
   ========================================= */

/* Scroll wrapper: allows horizontal scroll on narrow screens */
.cr2sm-file-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cr2sm-file-table {
    width: 100%;
    min-width: 480px; /* prevent crush below this */
    table-layout: auto;
    border-collapse: collapse;
}

/* File Name column: takes all remaining space */
.cr2sm-file-table .column-key {
    width: auto;
    max-width: 0; /* combined with overflow:hidden forces shrink */
}

.cr2sm-file-table .column-key strong,
.cr2sm-file-table .column-key .cr2sm-file-key {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Fixed-width columns so they never compress */
.cr2sm-file-table .column-size {
    width: 70px;
    min-width: 70px;
    text-align: right !important;
    white-space: nowrap;
    padding: 6px 8px !important;
}

.cr2sm-file-table .column-public {
    width: 46px;
    min-width: 46px;
    text-align: center !important;
    white-space: nowrap;
    padding: 6px 4px !important;
}

.cr2sm-file-table .column-action {
    width: 68px;
    min-width: 68px;
    text-align: center !important;
    white-space: nowrap;
    padding: 6px 4px !important;
}

/* Compact button styles */
.cr2sm-file-table .column-action .button,
.cr2sm-file-table .column-public .button {
    padding: 2px 8px;
    font-size: 12px;
    white-space: nowrap;
}

@media (max-width: 600px) {

    /* Scroll propre */
    .cr2sm-file-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Réduction globale */
    .cr2sm-file-table {
        min-width: 100%; /* IMPORTANT */
        font-size: 12px;
    }

    /* File name compressé intelligemment */
    .cr2sm-file-table .column-key {
        max-width: 140px;
    }

    .cr2sm-file-table .column-key strong,
    .cr2sm-file-table .column-key .cr2sm-file-key {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Colonnes compactes */
    .cr2sm-file-table .column-size {
        width: 55px;
        min-width: 55px;
        font-size: 11px;
    }

    .cr2sm-file-table .column-public {
        width: 40px;
        min-width: 40px;
    }

    .cr2sm-file-table .column-action {
        width: 55px;
        min-width: 55px;
    }

    /* Boutons plus petits */
    .cr2sm-file-table .button {
        padding: 2px 6px;
        font-size: 11px;
    }

    /* Nettoyage legacy */
    .cr2sm-file-table td::before {
        content: none !important;
    }
}
/* ======================================================
   Dashboard – action grid (replaces inline flex layout)
   ====================================================== */

.cr2sm-action-grid-flex {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.cr2sm-action-card-flex {
    flex: 1;
    min-width: 250px;
}

/* ======================================================
   Dashboard – Upsell card accent (replaces inline border/color)
   ====================================================== */

.cr2sm-dashboard-upsell {
    border-left: 4px solid #A020F0;
}

.cr2sm-dashboard-upsell h2 {
    color: #A020F0;
}

.cr2sm-upsell-btn {
    background-color: #A020F0 !important;
    border-color: #A020F0 !important;
}

/* ======================================================
   Dashboard – comparison table header colors
   ====================================================== */

.cr2sm-th-muted {
    color: #646970;
}

.cr2sm-th-pro {
    color: #2271b1;
}

.cr2sm-td-muted {
    color: #646970;
}

.cr2sm-td-pro {
    color: #2271b1;
    font-weight: 500;
}

/* ======================================================
   Files view – sort bar
   ====================================================== */

.cr2sm-sort-bar {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.cr2sm-sort-label {
    font-weight: 600;
    color: #444;
}

.cr2sm-sort-btn-active {
    background: #f0f0f1;
    border-color: #8c8f94;
}

/* ======================================================
   Files view – folder row
   ====================================================== */

.cr2sm-folder-row {
    background-color: #f9f9f9;
}

.cr2sm-folder-icon {
    margin-right: 5px;
    color: #666;
}

/* ======================================================
   Files view – security upsell card
   ====================================================== */

.cr2sm-security-card {
    opacity: 0.9;
}

.cr2sm-security-card-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.cr2sm-security-card-text {
    flex: 1;
    min-width: 200px;
}

/* ======================================================
   Settings – bucket security warning box
   ====================================================== */

.cr2sm-security-warning {
    margin-top: 10px;
    padding: 10px;
    border-left: 4px solid #f56e28;
    background: #fff8e5;
}

.cr2sm-security-warning-title {
    margin: 0;
    color: #d63638;
    font-weight: bold;
}

.cr2sm-security-warning-title .dashicons {
    color: #f56e28;
    vertical-align: text-bottom;
}

.cr2sm-security-warning-body {
    margin-top: 5px;
}

.cr2sm-security-warning-note {
    margin-top: 5px;
    font-size: 12px;
    color: #555;
}

/* ======================================================
   Settings – region input compact width
   ====================================================== */

.cr2sm-input-region {
    width: 100%;
    max-width: 150px;
}

/* ======================================================
   Settings – submit row spacing
   ====================================================== */

.cr2sm-submit-row {
    margin-top: 20px;
}

.cr2sm-btn-margin-left {
    margin-left: 10px;
}

.cr2sm-test-result {
    margin-left: 15px;
    vertical-align: middle;
}

/* ======================================================
   Upload view – server info box
   ====================================================== */

.cr2sm-server-info-box {
    background: #fcfcfc;
    border: 1px solid #f0f0f1;
    padding: 15px;
    margin-bottom: 20px;
}

.cr2sm-server-info-list {
    list-style: disc;
    margin: 10px 0 10px 20px;
}

.cr2sm-effective-limit-box {
    margin-top: 15px;
    padding: 10px;
    background: #fff;
    border-left: 4px solid #2271b1;
}

.cr2sm-effective-limit-label {
    margin: 0;
    font-size: 14px;
}

.cr2sm-effective-limit-value {
    font-size: 16px;
    font-weight: bold;
    color: #2271b1;
}

.cr2sm-effective-limit-note {
    margin-top: 8px;
}

/* Upload – Pro card preview */
.cr2sm-pro-card {
    max-width: 800px;
    opacity: 0.8;
}

.cr2sm-pro-preview-disabled {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(100%);
    margin-bottom: 20px;
}

.cr2sm-pro-dropzone {
    border: 2px dashed #ccc;
    padding: 40px;
    text-align: center;
    background: #fafafa;
}

.cr2sm-pro-dropzone .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: #ccc;
}

.cr2sm-pro-cta {
    text-align: center;
}

/* Upload result – rendered directly in view */
.cr2sm-upload-success {
    max-width: 800px;
    margin-top: 0;
}

/* ======================================================
   Shortcodes view
   ====================================================== */

.cr2sm-shortcodes-card {
    max-width: 800px;
    margin-top: 20px;
}

.cr2sm-shortcodes-inner {
    padding: 20px;
}

.cr2sm-shortcode-example {
    font-size: 16px;
    font-weight: bold;
}

.cr2sm-shortcodes-block-info {
    margin-top: 25px;
    padding: 15px;
    background: #f0f6fb;
    border-left: 4px solid #2271b1;
    border-radius: var(--cr2sm-radius);
}

.cr2sm-shortcodes-block-info h3 {
    margin-top: 0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2271b1;
}

.cr2sm-shortcodes-block-info p {
    margin: 0;
}

.cr2sm-shortcodes-note {
    background: #fff8e5;
    padding: 10px;
    border: 1px solid #f0c33c;
    border-radius: 4px;
    border-left: 4px solid #f0c33c;
    margin: 15px 0;
}

.cr2sm-shortcodes-note p {
    margin: 0;
    font-size: 13px;
}

.cr2sm-shortcodes-attrs {
    list-style-type: disc;
    margin-left: 20px;
    color: #666;
    line-height: 1.6;
}

.cr2sm-shortcodes-hr {
    margin: 30px 0;
    border: 0;
    border-top: 1px solid #ddd;
}

.cr2sm-shortcodes-upsell {
    background: #fff8e5;
    padding: 15px;
    border: 1px solid #f0c33c;
    border-radius: 4px;
}

.cr2sm-shortcodes-upsell h3 {
    margin-top: 0;
    color: #b36b00;
}

/* ======================================================
   Wizard view – layout helpers
   ====================================================== */

.cr2sm-wizard-existing-creds {
    text-align: center;
    margin-bottom: 30px;
}

.cr2sm-wizard-creds-box {
    background: #fff;
    padding: 20px;
    border: 1px solid #c3c4c7;
    margin-bottom: 20px;
}

.cr2sm-wizard-creds-icon {
    font-size: 30px;
    width: 30px;
    height: 30px;
    color: #2271b1;
    margin-bottom: 10px;
}

.cr2sm-wizard-creds-title {
    margin: 10px 0;
}

.cr2sm-wizard-creds-sub {
    margin: 0;
    color: #646970;
}

.cr2sm-wizard-creds-bucket {
    margin-top: 5px;
    font-size: 13px;
}

.cr2sm-wizard-creds-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.cr2sm-wizard-step2-wrap {
    text-align: center;
    display: none;
}

.cr2sm-wizard-spinner-block {
    margin: 40px 0;
}

.cr2sm-wizard-spinner-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto;
}

.cr2sm-wizard-success-icon {
    font-size: 50px;
    width: 50px;
    height: 50px;
    color: #007017;
}

.cr2sm-wizard-success-btn-row {
    margin-top: 20px;
}

.cr2sm-wizard-error-icon {
    font-size: 50px;
    width: 50px;
    height: 50px;
    color: #d63638;
}

.cr2sm-wizard-error-btn-row {
    margin-top: 20px;
}

.cr2sm-wizard-step3-wrap {
    text-align: center;
    display: none;
}

.cr2sm-wizard-rocket-icon {
    font-size: 60px;
    width: 60px;
    height: 60px;
    color: #2271b1;
    margin-bottom: 20px;
}

.cr2sm-wizard-finish-btn-row {
    margin-top: 30px;
}

/* ======================================================
   Upgrade to Pro submenu item colour
   Applied via admin_head target on the menu slug
   ====================================================== */

#toplevel_page_cr2sm-lite-dashboard .wp-submenu li:last-child > a {
    color: #f56e28 !important;
    font-weight: bold !important;
}

/* ======================================================
   Breadcrumbs Navigation (Aligned with Pro design)
   ====================================================== */
.cr2sm-breadcrumbs {
    padding: 15px 20px;
    background: #fcfcfc;
    border: 1px solid #c3c4c7;
    margin-bottom: 25px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.cr2sm-breadcrumbs .cr2sm-crumb-item {
    cursor: pointer;
    color: #f38020;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s ease;
}

.cr2sm-breadcrumbs .cr2sm-crumb-item:hover {
    color: #c4620e;
}

.cr2sm-breadcrumbs .cr2sm-crumb-item::after {
    content: '\f345'; /* dashicons-arrow-right-alt2 */
    font-family: dashicons;
    margin-left: 10px;
    font-size: 12px;
    color: #646970;
    opacity: 0.5;
}

.cr2sm-breadcrumbs .cr2sm-crumb-item:last-child {
    color: #1d2327;
    cursor: default;
    font-weight: 700;
}

.cr2sm-breadcrumbs .cr2sm-crumb-item:last-child::after {
    content: '';
}

.cr2sm-breadcrumbs .cr2sm-breadcrumbs-back {
    margin-right: 15px;
    height: 32px !important;
    width: 32px !important;
    min-width: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff !important;
    border: 1px solid #c3c4c7 !important;
    border-radius: 4px !important;
    color: #646970 !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.cr2sm-breadcrumbs .cr2sm-breadcrumbs-back:hover {
    background: #f6f7f7 !important;
    border-color: #f38020 !important;
    color: #f38020 !important;
}

/* ======================================================
   Focus Reset (Remove ugly default browser outline/black border)
   ====================================================== */
.cr2sm-admin a:focus,
.cr2sm-admin button:focus,
.cr2sm-admin .cr2sm-crumb-item:focus,
.cr2sm-admin a:active,
.cr2sm-admin button:active,
.cr2sm-admin .cr2sm-crumb-item:active {
    outline: none !important;
    box-shadow: none !important;
}

/* ======================================================
   Shortcodes View Premium Styles
   ====================================================== */
.cr2sm-shortcode-example {
    display: block !important;
    background: #f6f7f7 !important;
    border: 1px solid #c3c4c7 !important;
    border-radius: 4px !important;
    padding: 12px 15px !important;
    font-family: monospace !important;
    font-size: 13px !important;
    color: #1d2327 !important;
    margin: 15px 0 !important;
    word-break: break-all !important;
}

.cr2sm-shortcodes-attrs-list {
    margin: 15px 0 !important;
    padding-left: 20px !important;
    list-style-type: disc !important;
}

.cr2sm-shortcodes-attrs-list li {
    margin-bottom: 8px !important;
    line-height: 1.5 !important;
}

.cr2sm-shortcodes-attrs-list code {
    font-weight: bold !important;
    color: #000 !important;
    background: #f0f0f1 !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
}

.cr2sm-info-box {
    background: #f0f6fc !important;
    border-left: 4px solid #72aee6 !important;
    padding: 12px 15px !important;
    border-radius: 0 4px 4px 0 !important;
    margin: 15px 0 !important;
}

.cr2sm-info-box h4 {
    margin: 0 0 6px 0 !important;
    color: #0c3d5f !important;
}

.cr2sm-info-box p {
    margin: 0 !important;
    color: #1d2327 !important;
    line-height: 1.4 !important;
}

.cr2sm-pro-feature-tag {
    background: #f56e28 !important;
    color: #fff !important;
    padding: 2px 6px !important;
    font-size: 10px !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
    border-radius: 3px !important;
    margin-left: 6px !important;
    vertical-align: middle !important;
    display: inline-block !important;
}

.cr2sm-pro-feature-list {
    margin: 15px 0 !important;
    padding-left: 0 !important;
    list-style: none !important;
}

.cr2sm-pro-feature-list li {
    position: relative !important;
    padding-left: 20px !important;
    margin-bottom: 10px !important;
    line-height: 1.4 !important;
}

.cr2sm-pro-feature-list li::before {
    content: "\f147" !important; /* dashicons-yes */
    font-family: dashicons !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    color: #2271b1 !important;
    font-size: 16px !important;
    width: 16px !important;
    height: 16px !important;
}

/* ======================================================
   Dashboard – Architectural Note
   ====================================================== */
.cr2sm-architectural-note {
    margin-top: 15px !important;
    max-width: 900px;
}

/* Document Sync Notice Card */
.cr2sm-admin .cr2sm-doc-sync-notice {
    margin: 0 0 20px 0 !important;
    padding: 10px 15px !important;
    border-left-color: var(--cr2sm-primary) !important;
    background: #fdf6f0 !important; /* Subtle warm orange background */
}

.cr2sm-admin .cr2sm-doc-sync-notice p {
    margin: 0 !important;
    color: var(--cr2sm-text-main) !important;
}