/**
 * Stylesheet for Printable Kindergarten Math Worksheet Generator
 * 
 * PLR DEVELOPER NOTE: This file uses generic class names (mwg- prefix) to prevent 
 * file path corruption or styling conflicts during the rebranding process.
 */

/* ==========================================================================
   1. MAIN GRID LAYOUT & FSE VIEWPORT BREAKOUT
   ========================================================================== */
.mwg-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

.mwg-container * {
    box-sizing: border-box;
}

/* 
 * PLR DEVELOPER NOTE: Full Site Editing (FSE) Viewport Breakout
 * Modern WordPress block themes (like Twenty Twenty-Five) enforce strict, narrow max-widths
 * (typically 620px to 650px) on direct children of post content blocks. This CSS calculation 
 * forces the app workspace to expand gracefully to full-width, resolving layout cropping.
 */
.entry-content .mwg-container,
.post-content .mwg-container,
.wp-block-post-content .mwg-container,
.wp-block-post-content > .mwg-container {
    max-width: 1300px !important;
    width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
    position: relative;
    left: 0;
    padding-left: 30px !important;
    padding-right: 30px !important;
}

/* ==========================================================================
   2. LEFT SIDEBAR: CONTROL PANEL
   ========================================================================== */
.mwg-sidebar {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e4e7;
    height: fit-content;
}

.mwg-sidebar h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.25rem;
    color: #1d2327;
    border-bottom: 1px solid #f0f0f1;
    padding-bottom: 10px;
}

.mwg-control-group {
    margin-bottom: 15px;
}

.mwg-control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #2c3338;
    font-size: 14px;
}

.mwg-control-group select,
.mwg-control-group input[type="text"],
.mwg-control-group input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.mwg-control-group input[type="range"] {
    width: 100%;
    margin-top: 5px;
}

.mwg-checkbox-group label {
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ==========================================================================
   3. ADMINISTRATIVE PRESETS (AJAX UI)
   ========================================================================== */
.mwg-admin-presets-box {
    background: #f0f6fc;
    padding: 12px;
    border-radius: 6px;
    border: 1px dashed #2271b1;
    margin-bottom: 20px;
}

.mwg-admin-presets-box label {
    display: block;
    font-size: 13px;
    font-weight: bold;
    color: #2271b1;
    margin-bottom: 6px;
}

.mwg-admin-presets-box select {
    width: 100%;
    padding: 6px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    margin-bottom: 8px;
}

.mwg-admin-presets-box input[type="text"] {
    font-size: 12px;
    padding: 6px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    flex: 1;
}

.mwg-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* PLR DEVELOPER NOTE: Styling for the hidden shortcode display box and copy button */
#mwg_shortcode_display {
    margin-top: 10px;
    padding: 8px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    font-size: 11px;
}

.mwg-btn-copy {
    background: #f0f0f1;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 10px;
    cursor: pointer;
    color: #2c3338;
    transition: all 0.2s ease;
}

.mwg-btn-copy:hover {
    background: #e2e4e7;
}

/* ==========================================================================
   4. ACTION BUTTONS
   ========================================================================== */
.mwg-actions {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mwg-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease;
}

.mwg-btn-primary {
    background: #2271b1;
    color: #ffffff;
}

.mwg-btn-primary:hover {
    background: #135e96;
}

.mwg-btn-secondary {
    background: #1d2327;
    color: #ffffff;
}

.mwg-btn-secondary:hover {
    background: #2c3338;
}

/* ==========================================================================
   5. RIGHT AREA: LIVE PREVIEW WORKSPACE (PAGINATION ENGINE)
   ========================================================================== */
.mwg-preview-area {
    background: #f0f0f1;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #e2e4e7;
    display: flex;
    flex-direction: column; /* Stack multiple pages vertically */
    align-items: center;    /* Center the pages horizontally */
    gap: 40px;              /* Create a realistic gap between printed pages */
    overflow-y: auto;
    max-height: 900px;
}

/* Simulates a standard US Letter page (8.5 x 11 inches) at 96 DPI */
.mwg-paper-preview {
    background: #ffffff;
    width: 100%;
    max-width: 816px; 
    min-height: 1056px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    padding: 40px;
    position: relative;
    color: #000;
    flex-shrink: 0; /* Prevents flexbox from squishing the pages vertically */
}

/* ==========================================================================
   6. WORKSHEET INTERNAL STYLES (Rendered by JS)
   ========================================================================== */
.mwg-worksheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    border-bottom: 2px solid #000;
    padding-bottom: 20px;
}

.mwg-worksheet-title {
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    margin: 0 0 20px 0;
    font-family: "Comic Sans MS", "Chalkboard SE", sans-serif; /* Child-friendly font fallback */
}

.mwg-student-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-size: 16px;
    font-weight: bold;
}

.mwg-student-info span {
    display: inline-block;
    min-width: 250px;
    border-bottom: 2px solid #000;
}

.mwg-emoji-widget {
    display: flex;
    gap: 10px;
}

.mwg-emoji-widget svg {
    width: 40px;
    height: 40px;
    stroke: #000;
    stroke-width: 2;
    fill: none;
}

.mwg-logo-container {
    max-width: 150px;
    max-height: 100px;
}

.mwg-logo-container img {
    max-width: 100%;
    height: auto;
}

/* Math Problem Grid */
.mwg-problem-grid {
    display: grid;
    gap: 30px;
}

.mwg-grid-1-col {
    grid-template-columns: 1fr;
}

.mwg-grid-2-col {
    grid-template-columns: 1fr 1fr;
}

/* Auto-adjusting flex layout to safely prevent vertical cell overlap */
.mwg-problem-cell {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 25px 20px;
    min-height: 240px; /* ~2.5 inches of vertical clearance */
    height: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
}

/* Keeps the structural math equation in a single horizontal row on all themes */
.mwg-problem-cell > div {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    flex-wrap: nowrap; /* Forces equation structure to stay horizontal */
}

/* Symmetrical visual wrapping with gap control */
.mwg-visual-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-content: center;
    max-width: 100%;
}

.mwg-visual-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}

.mwg-visual-icon svg {
    width: 100%;
    height: 100%;
}

.mwg-answer-box {
    width: 80px;
    height: 80px;
    border: 3px dashed #888;
    border-radius: 8px;
    display: inline-block;
    background: #fff;
    flex-shrink: 0; /* Prevents answer box from squishing in narrow layouts */
}

/* ==========================================================================
   7. RESPONSIVE DESIGN
   ========================================================================== */
@media screen and (max-width: 900px) {
    .mwg-container {
        grid-template-columns: 1fr;
    }
    
    .entry-content .mwg-container,
    .post-content .mwg-container,
    .wp-block-post-content .mwg-container,
    .wp-block-post-content > .mwg-container {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .mwg-sidebar {
        order: 2;
    }
    
    .mwg-preview-area {
        order: 1;
        padding: 10px;
    }
    
    .mwg-paper-preview {
        padding: 20px;
    }
}