/*!
	cubicFUSION Admin Enhancer \ Widget Grid Layout
	Enhanced CSS Grid Layout for CMB Widget Settings
*/

/* =============================================
   WIDGET GRID LAYOUT - 2 Cards Per Row
   Using CMB2 Groups for proper semantic structure
   ============================================= */

/* Container: 2-column grid layout for widget cards */
.cmbhandle-title {
    display: none !important;
}

body[class*=cf_plugins_shortcodes] .cmb-form .cmb-field-list {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px !important;
    align-items: start;
}

/* Non-widget rows (search, cache info, titles) span full width */
body[class*=cf_plugins_shortcodes] .cmb-row:not(.cf-widget-card) {
    grid-column: 1 / -1 !important;
}

/* Widget cards (CMB2 groups) - each card is a single grid item */
body[class*=cf_plugins_shortcodes] .cmb-row.cf-widget-card,
body[class*=cf_plugins_shortcodes] .cf-widget-card.cmb-type-group {
    grid-column: span 1 !important;
    width: 100% !important;
    float: none !important;
    background: #fff !important;
    border: 1px solid #dcdcde !important;
    border-radius: 8px !important;
    overflow: hidden;
    transition: all 0.2s ease;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Hover effect on widget cards */
body[class*=cf_plugins_shortcodes] .cf-widget-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-color: var(--cf-primary) !important;
}

/* Remove default CMB2 group styling */
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-repeat-group-wrap,
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-repeatable-grouping,
body[class*=cf_plugins_shortcodes] .cf-widget-card .postbox {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-group-title,
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmbhandle {
    display: none !important;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-field-list {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
}

/* Card title header */
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-type-title {
    background: var(--cf-section-bg) !important;
    border: none !important;
    border-left: 4px solid var(--cf-primary) !important;
    padding: 16px !important;
    margin: 0 !important;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-type-title h3,
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-type-title .cmb2-metabox-title {
    margin: 0 !important;
    padding: 6px 12px;
    background: transparent !important;
    color: var(--cf-text-primary);
    display: inline-block;
    font-size: 14px !important;
    font-weight: 600 !important;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-type-title .dashicons {
    color: var(--cf-text-primary);
}

/* Card content fields */
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row:not(.cmb-type-title) {
    padding: 16px !important;
    margin: 0 !important;
    background: var(--cf-container-bg) !important;
    border: none !important;
}

/* Field labels */
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-th label {
    font-weight: 500;
    font-size: 13px;
    color: var(--cf-text-secondary);
}

/* Input fields */
body[class*=cf_plugins_shortcodes] .cf-widget-card input[type="text"] {
    width: 100%;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card input[type="text"][readonly] {
    background: var(--cf-section-bg);
    border-color: var(--cf-border);
    color: var(--cf-text-secondary);
    cursor: default;
    font-family: monospace;
    font-size: 13px;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card input[type="checkbox"] {
    margin-top: 4px;
}

/* Table layout fields inside cards */
body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row.table-layout {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 16px;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row.table-layout .cmb-th {
    flex: 0 0 auto;
    min-width: 250px;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row.table-layout .cmb-th label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row.table-layout .cmb-td {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row.table-layout .cmb-td input[type="text"] {
    flex: 1 1 auto;
    width: 100%;
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row.table-layout .cmb-td .dashicons {
    flex: 0 0 auto;
}

/* Clipboard icon styling */
body[class*=cf_plugins_shortcodes] .cf-widget-card .dashicons-clipboard {
    color: var(--cf-primary);
    cursor: pointer;
    transition: var(--cf-transition);
}

body[class*=cf_plugins_shortcodes] .cf-widget-card .dashicons-clipboard:hover {
    color: var(--cf-primary-hover);
    transform: scale(1.1);
}

/* =============================================
   RESPONSIVE - Grid & Mobile
   ============================================= */

/* Tablet: Single column grid */
@media screen and (max-width: 1200px) {
    body[class*=cf_plugins_shortcodes] .cmb-form .cmb-field-list {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile: Stack CMB rows */
@media screen and (max-width: 782px) {
    /* Widget cards - full width with padding adjustment */
    body[class*=cf_plugins_shortcodes] .cf-widget-card {
        padding: 0 !important;
    }

    /* Stack table cells */
    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-row {
        display: block !important;
    }

    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-th,
    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-td {
        display: block !important;
        width: 100% !important;
        min-width: 100% !important;
        text-align: left !important;
        padding: 0 15px !important;
        margin: 0 !important;
    }

    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-th {
        padding-top: 15px !important;
        padding-bottom: 5px !important;
    }

    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-td {
        padding-bottom: 15px !important;
    }

    /* Full width inputs */
    body[class*=cf_plugins_shortcodes] .cf-widget-card input[type="text"],
    body[class*=cf_plugins_shortcodes] .cf-widget-card input[type="number"],
    body[class*=cf_plugins_shortcodes] .cf-widget-card select,
    body[class*=cf_plugins_shortcodes] .cf-widget-card textarea {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Descriptions always on new line */
    body[class*=cf_plugins_shortcodes] .cmb2-metabox-description {
        display: block !important;
        width: 100% !important;
        margin-top: 8px !important;
    }

    /* Code textareas */
    body[class*=cf_plugins_shortcodes] .cmb2-textarea-code,
    body[class*=cf_plugins_shortcodes] .CodeMirror {
        width: 100% !important;
        font-size: 12px !important;
    }

    /* Widget header - adjust padding */
    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-group-title {
        padding: 12px 15px !important;
    }
}

/* Small mobile: Even more compact */
@media screen and (max-width: 600px) {
    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-th,
    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-td {
        padding: 0 10px !important;
    }

    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-th {
        padding-top: 10px !important;
    }

    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-td {
        padding-bottom: 10px !important;
    }

    body[class*=cf_plugins_shortcodes] .cf-widget-card .cmb-group-title {
        padding: 10px !important;
        font-size: 14px !important;
    }
}