/* ==========================================================================
   Cards - Collapsible Sections, Form Cards, Content Blocks
   ========================================================================== */

/* --- Card Base --- */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: var(--space-5) var(--space-6);
    margin-bottom: var(--space-5);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 0;
}

/* --- Collapsible Section Headers (Plus/Minus Pattern) --- */
div.formPlaceHolder > div.formElement[onclick],
div.formElement[onclick*="alterLayer"] {
    cursor: pointer;
    padding: var(--space-3) var(--space-4);
    margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-6));
    margin-bottom: var(--space-4);
    background-color: var(--body-bg);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transition: background-color var(--transition);
    display: flex;
    align-items: center;
}

div.formPlaceHolder > div.formElement[onclick]:hover,
div.formElement[onclick*="alterLayer"]:hover {
    background-color: var(--primary-light);
}

/* --- Plus/Minus Icon Modernization --- */
div.plusminus {
    float: left;
    margin-right: var(--space-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background-color: var(--primary);
    transition: all var(--transition);
    position: relative;
}

div.plusminus img {
    display: none;
}

/* Show + or - based on the img alt attribute */
div.plusminus::after {
    content: "−";
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
}

/* When section is collapsed (img alt="Expand"), show + */
div.plusminus:has(img[alt="Expand"])::after {
    content: "+";
}

/* Fallback for browsers without :has() — use JS-toggled class */
div.plusminus.collapsed::after {
    content: "+";
}

div.formElement[onclick]:hover div.plusminus {
    background-color: var(--primary-hover);
}

/* --- Section Heading (blue_heading modernized) --- */
div.blue_heading {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    letter-spacing: 0.2px;
    text-transform: uppercase;
    flex: 1;
}

/* --- Form Cards (formPlaceHolder modernized) --- */
div.formPlaceHolder {
    margin: 0 0 -1px 0;
    background-color: var(--card-bg);
    border-radius: 0;
    padding: var(--space-5) var(--space-6);
    box-shadow: none;
    transition: box-shadow var(--transition);
}

/* First card in any form context */
form > div.formPlaceHolder:first-child,
form > div.formPlaceHolder:first-of-type,
div.formPlaceHolderLine + div.formPlaceHolder,
.admin-content > div.formPlaceHolder:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

/* Last card before a divider or end */
form > div.formPlaceHolder:last-child,
form > div.formPlaceHolder:last-of-type {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* Card right before a formPlaceHolderLine gets bottom radius */
div.formPlaceHolder + div.formPlaceHolderLine {
    margin-top: 0;
}

/* Redesigned page cards (override back to individual cards) */
.cat-card, .url-card, .sync-card, .prod-card,
.campaign-card, .ecom-search-card, .admin-user-card,
.msg-card, .camp-add-card, .camp-grid-card,
.camp-products-card, .dash-card,
.blist-search-card, .blist-grid-card,
.url-grid-section, .cat-grid-card, .cat-export-bar,
.sync-logs-card, .sync-info-bar, .camp-filter-bar,
.url-export-bar, .prod-search-card, .prod-results-card,
.prod-card, .admin-user-grid-section {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow) !important;
    margin-bottom: 20px !important;
    margin-top: 0 !important;
}

div.formPlaceHolder:empty {
    display: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border: none;
}

div.formPlaceHolder:hover {
}

/* --- Divider Line --- */
div.formPlaceHolderLine {
    border: none;
    height: 0;
    border-top: 1px solid var(--border);
    margin: var(--space-6) 0;
    padding: 0;
    background: none;
    box-shadow: none;
}

/* --- Form Row --- */
div.formElement {
    margin: 0px 0px var(--space-4) 0px;
    vertical-align: middle;
}

div.formElement:last-child {
    margin-bottom: 0;
}

/* --- Form Label --- */
div.formElementLabel {
    float: none;
    width: 130px;
    min-width: 130px;
    flex-shrink: 0;
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    padding-top: 10px;
    line-height: 1.4;
}

/* --- Instruction Text --- */
.instructionText {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    line-height: 1.6;
}

/* --- Dual ListBox Container --- */
div.formElement > div[style*="float: left"] {
    float: none !important;
    display: inline-block;
    vertical-align: top;
    margin-right: var(--space-3);
    margin-bottom: var(--space-3);
}

/* Dual ListBox - Transfer Buttons Column */
div.formElement > div[style*="float: left"][style*="margin-top: 15px"] {
    display: inline-flex !important;
    flex-direction: column;
    gap: var(--space-2);
    align-items: center;
    justify-content: center;
    margin-top: 20px !important;
    padding: 0 var(--space-2);
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background-color: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background-color: var(--info-bg);
    color: var(--info);
}

/* --- Action Bar (Submit/Delete buttons at top of forms) --- */
div.formPlaceHolder > div.formElement:first-child:has(input[type="submit"]) {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
}

/* --- Bold Section Headers inside cards --- */
div.formPlaceHolder > b,
div.formPlaceHolder > strong {
    display: block;
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

/* --- Info/Help Text --- */
.help-text {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* --- Quick-Link Dashboard Cards --- */
a[style*="text-decoration: none"] > div {
    transition: all var(--transition) !important;
}

a[style*="text-decoration: none"] > div:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--primary) !important;
}
