/* ═══════════════════════════════════════════════════════════════════
   AI Playground — Teacher Content Generation Studio
   Teal brand #004D40 | NEP 2020 & NCF 2023 aligned
   ═══════════════════════════════════════════════════════════════════ */

.slms-playground {
    --pg-primary: #004D40;
    --pg-primary-light: #e0f2f1;
    --pg-primary-hover: #00695C;
    --pg-primary-glow: rgba(0, 77, 64, 0.15);
    --pg-bg: #f8fafc;
    --pg-card-bg: #ffffff;
    --pg-border: #e2e8f0;
    --pg-text: #1a2327;
    --pg-muted: #64748b;
    --pg-radius: 10px;
    --pg-radius-sm: 6px;
    --pg-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --pg-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

/* ─── Print Header (screen-hidden) ────────────────────────────── */
.pg-print-header {
    display: none;
}

/* ─── Context Bar ─────────────────────────────────────────────── */
.pg-context-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--pg-card-bg);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius);
    margin-bottom: 16px;
}

.pg-context-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--pg-primary);
    margin-right: 4px;
    white-space: nowrap;
}

.pg-select,
.pg-input {
    padding: 6px 10px;
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-sm);
    font-size: 13px;
    color: var(--pg-text);
    background: #fff;
    min-width: 100px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.pg-select {
    cursor: pointer;
}

.pg-input {
    max-width: 140px;
}

.pg-select:focus,
.pg-input:focus {
    outline: none;
    border-color: var(--pg-primary);
    box-shadow: 0 0 0 2px var(--pg-primary-glow);
}

.pg-input::placeholder {
    color: var(--pg-muted);
}

.pg-nep-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--pg-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    white-space: nowrap;
    margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   PROMPT CARD — dark themed, prominent, AI-branded
   Inspired by the "AI Exam Generator" reference layout
   ═══════════════════════════════════════════════════════════════════ */

.pg-prompt-card {
    background: linear-gradient(135deg, #002018 0%, #003D33 40%, #00574a 100%);
    border: 1px solid rgba(0, 200, 150, 0.2);
    border-radius: 14px;
    padding: 28px 24px 24px;
    margin-bottom: 20px;
    box-shadow: 0 6px 24px rgba(0, 77, 64, 0.2);
}

.pg-prompt-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    justify-content: center;
}

.pg-prompt-card__icon {
    font-size: 22px;
    color: #4dd0b0;
    line-height: 1;
}

.pg-prompt-card__titles {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pg-prompt-card__title {
    font-size: 18px;
    font-weight: 700;
    color: #4dd0b0;
    letter-spacing: 0.01em;
}

.pg-prompt-card__subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
}

.pg-prompt-card__input-row {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pg-prompt-card__input-row:focus-within {
    border-color: #4dd0b0;
    box-shadow: 0 0 0 3px rgba(77, 208, 176, 0.15);
}

.pg-prompt-card__input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    padding: 10px 8px;
    min-width: 0;
}

.pg-prompt-card__input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.pg-prompt-card__send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--pg-primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.pg-prompt-card__send:hover {
    background: #4dd0b0;
    color: #002018;
    transform: scale(1.05);
}

.pg-prompt-card__send:active {
    transform: scale(0.97);
}

.pg-prompt-card__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Prompt Attachments (File, Image, Voice) ─────────────────── */
.pg-prompt-attachments {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px 0;
    flex-wrap: wrap;
}

.pg-attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.pg-attach-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.pg-attach-btn svg {
    flex-shrink: 0;
}

.pg-voice-btn--listening {
    background: #c62828 !important;
    color: #fff !important;
    border-color: #c62828 !important;
    animation: pg-voice-pulse 1s ease-in-out infinite;
}

@keyframes pg-voice-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

.pg-attachment-name {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(77, 208, 176, 0.2);
    border-radius: 4px;
    font-size: 11px;
    color: #4dd0b0;
    max-width: 200px;
    overflow: hidden;
}

.pg-attachment-name__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-attachment-name__remove {
    border: none;
    background: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}

/* ─── Tools Section ───────────────────────────────────────────── */
.pg-tools-section {
    margin-bottom: 20px;
}

.pg-tools-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--pg-text);
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--pg-border);
}

.pg-tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.pg-tool-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px 10px;
    background: var(--pg-card-bg);
    border: 2px solid var(--pg-border);
    border-radius: var(--pg-radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    user-select: none;
    text-align: center;
}

.pg-tool-card:hover {
    border-color: var(--pg-primary);
    box-shadow: var(--pg-shadow);
}

/* Single-select: selected state */
.pg-tool-card--selected {
    border-color: var(--pg-primary);
    background: var(--pg-primary-light);
    box-shadow: var(--pg-shadow-md);
}

.pg-tool-card__check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border: 2px solid var(--pg-border);
    border-radius: 50%;
    transition: background 0.2s, border-color 0.2s;
}

.pg-tool-card--selected .pg-tool-card__check {
    background: var(--pg-primary);
    border-color: var(--pg-primary);
}

.pg-tool-card--selected .pg-tool-card__check::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.pg-tool-card__emoji {
    font-size: 24px;
    line-height: 1;
}

.pg-tool-card__name {
    font-size: 12px;
    font-weight: 600;
    color: var(--pg-text);
    line-height: 1.3;
}

.pg-tool-card__badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pg-tool-card__badge--teacher {
    background: var(--pg-primary-light);
    color: var(--pg-primary);
}

.pg-tool-card__badge--student {
    background: #e8f4fd;
    color: #1565c0;
}

.pg-tool-card__badge--both {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ─── Generate Button ─────────────────────────────────────────── */
.pg-generate-row {
    text-align: center;
    margin-bottom: 16px;
}

.pg-generate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 48px;
    background: var(--pg-primary);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: var(--pg-shadow-md);
}

.pg-generate-btn:hover {
    background: var(--pg-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 77, 64, 0.25);
}

.pg-generate-btn:active {
    transform: translateY(0);
}

.pg-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ─── Output Area / Editor ────────────────────────────────────── */
.pg-output-area {
    margin-bottom: 16px;
}

.pg-editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #f1f5f9;
    border: 1px solid var(--pg-border);
    border-bottom: none;
    border-radius: var(--pg-radius) var(--pg-radius) 0 0;
}

.pg-editor-toolbar button {
    padding: 6px 10px;
    background: var(--pg-card-bg);
    border: 1px solid var(--pg-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--pg-text);
    transition: background 0.15s;
    line-height: 1;
}

.pg-editor-toolbar button:hover {
    background: var(--pg-primary-light);
    border-color: var(--pg-primary);
}

.pg-toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--pg-border);
    margin: 0 4px;
    align-self: center;
    flex-shrink: 0;
}

.pg-editor {
    min-height: 400px;
    padding: 20px 24px;
    background: var(--pg-card-bg);
    border: 1px solid var(--pg-border);
    border-radius: 0 0 var(--pg-radius) var(--pg-radius);
    font-size: 14px;
    line-height: 1.7;
    color: var(--pg-text);
    outline: none;
    overflow-y: auto;
}

.pg-editor:focus {
    border-color: var(--pg-primary);
    box-shadow: 0 0 0 2px var(--pg-primary-glow);
}

/* Editor content styling */
.pg-editor h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--pg-primary);
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--pg-primary-light);
}

.pg-editor h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--pg-text);
    margin: 18px 0 8px;
}

.pg-editor table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.pg-editor th,
.pg-editor td {
    padding: 8px 12px;
    border: 1px solid var(--pg-border);
    text-align: left;
    font-size: 13px;
}

.pg-editor th {
    background: var(--pg-primary-light);
    font-weight: 600;
    color: var(--pg-primary);
}

.pg-editor ul,
.pg-editor ol {
    margin: 8px 0;
    padding-left: 24px;
}

.pg-editor li {
    margin-bottom: 4px;
}

/* ─── Visual Output Types (Mermaid, Chart, Image) ─────────────── */
.pg-mermaid-output {
    text-align: center;
    padding: 24px 0;
}

.pg-mermaid-output svg {
    max-width: 100%;
    height: auto;
}

.pg-mermaid-error {
    padding: 16px;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 8px;
    color: #e65100;
    font-size: 13px;
}

.pg-mermaid-error pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
    color: var(--pg-text);
    margin-top: 8px;
}

.pg-chart-output {
    text-align: center;
    padding: 16px 0;
}

.pg-chart-output canvas {
    max-width: 100%;
}

.pg-image-output {
    text-align: center;
    padding: 20px 0;
}

.pg-image-output img {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.pg-image-note {
    font-size: 12px;
    color: var(--pg-muted);
    margin-top: 8px;
    font-style: italic;
}

/* ─── Download Toolbar ────────────────────────────────────────── */
.pg-download-toolbar {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.pg-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    background: var(--pg-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.pg-download-btn:hover {
    background: var(--pg-primary-hover);
}

/* ─── Credits Indicator ───────────────────────────────────────── */
.pg-credits-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--pg-primary);
    background: var(--pg-primary-light);
    border-radius: var(--pg-radius-sm);
    margin-bottom: 12px;
    width: fit-content;
}

.pg-credits-warn {
    color: #c62828;
    font-weight: 700;
}

/* ─── Loading Skeleton ────────────────────────────────────────── */
.pg-loading {
    padding: 24px;
    background: var(--pg-card-bg);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius);
    margin-bottom: 16px;
}

.pg-loading__bar {
    height: 16px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    margin-bottom: 12px;
    animation: pg-shimmer 1.5s ease-in-out infinite;
}

.pg-loading__bar--short {
    width: 60%;
}

.pg-loading__bar--med {
    width: 80%;
}

.pg-loading__text {
    text-align: center;
    color: var(--pg-muted);
    font-size: 13px;
    margin: 16px 0 0;
}

@keyframes pg-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ─── Share Bar ───────────────────────────────────────────────── */
.pg-share-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--pg-card-bg);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius);
    margin-bottom: 16px;
}

.pg-share-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--pg-text);
    margin-right: 4px;
}

.pg-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--pg-card-bg);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--pg-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.pg-share-btn:hover {
    border-color: var(--pg-primary);
    color: var(--pg-primary);
    background: var(--pg-primary-light);
}

.pg-share-btn svg {
    flex-shrink: 0;
}

.pg-share-btn--whatsapp:hover {
    border-color: #25d366;
    color: #25d366;
    background: #e8f8ef;
}

.pg-share-btn--facebook:hover {
    border-color: #1877f2;
    color: #1877f2;
    background: #e8f0fe;
}

.pg-share-btn--twitter:hover {
    border-color: #1da1f2;
    color: #000;
    background: #f0f7fc;
}

.pg-share-btn--print:hover {
    border-color: var(--pg-primary);
    background: var(--pg-primary);
    color: #fff;
}

.pg-share-btn--share:hover {
    border-color: var(--pg-primary);
    background: var(--pg-primary);
    color: #fff;
}

/* ─── Toast ───────────────────────────────────────────────────── */
.pg-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--pg-radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    z-index: 9999;
    animation: pg-toast-in 0.3s ease-out;
    max-width: 360px;
    box-shadow: var(--pg-shadow-md);
}

.pg-toast--success {
    background: #2e7d32;
}

.pg-toast--error {
    background: #c62828;
}

.pg-toast--info {
    background: var(--pg-primary);
}

@keyframes pg-toast-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Desktop: hide mobile-only elements */
.pg-tools-selected-label {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .pg-context-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .pg-select,
    .pg-input {
        width: 100%;
        max-width: none;
    }

    .pg-nep-badge {
        margin-left: 0;
        align-self: flex-start;
    }

    /* Collapsible tool sections on mobile */
    .pg-tools-heading {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--pg-card-bg);
        border: 1px solid var(--pg-border);
        border-radius: var(--pg-radius);
        margin-bottom: 4px;
        user-select: none;
    }

    .pg-tools-heading::after {
        content: '\25BC';
        font-size: 10px;
        color: var(--pg-muted);
        transition: transform 0.2s;
    }

    .pg-tools-heading.pg-tools-heading--open::after {
        transform: rotate(180deg);
    }

    .pg-tool-grid {
        display: none;
        grid-template-columns: repeat(2, 1fr);
        margin-top: 8px;
    }

    .pg-tool-grid.pg-tool-grid--open {
        display: grid;
    }

    .pg-tools-selected-label {
        display: inline;
        font-size: 12px;
        color: var(--pg-primary);
        font-weight: 500;
        margin-left: 6px;
    }

    .pg-prompt-card {
        padding: 20px 16px;
    }

    .pg-prompt-card__title {
        font-size: 16px;
    }

    .pg-generate-btn {
        width: 100%;
        padding: 14px 24px;
    }

    .pg-share-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .pg-share-btn {
        justify-content: center;
    }

    .pg-editor {
        min-height: 250px;
        padding: 14px 16px;
    }
}

@media (max-width: 480px) {
    .pg-tool-grid {
        grid-template-columns: 1fr;
    }

    .pg-tool-card {
        flex-direction: row;
        gap: 10px;
        padding: 10px 12px;
        text-align: left;
    }

    .pg-tool-card__check {
        position: static;
        order: -1;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   PRINT STYLES — for "Print / Save as PDF"
   ═══════════════════════════════════════════════════════════════════ */

@media print {
    /* Hide everything except the output content */
    .slms-sidebar,
    .slms-sidebar-overlay,
    .slms-main-topbar,
    .pg-context-bar,
    .pg-prompt-card,
    .pg-tools-section,
    .pg-generate-row,
    .pg-editor-toolbar,
    .pg-share-bar,
    .pg-loading,
    .pg-toast {
        display: none !important;
    }

    /* Show print header */
    .pg-print-header {
        display: block !important;
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 2px solid #004D40;
    }

    .pg-print-header__meta {
        font-size: 14px;
        font-weight: 600;
        color: #004D40;
    }

    .pg-print-header__teacher {
        font-size: 12px;
        color: #333;
        margin-top: 4px;
    }

    /* Show output area */
    .pg-output-area {
        display: block !important;
        border: none !important;
        box-shadow: none !important;
    }

    .pg-editor {
        border: none !important;
        padding: 0 !important;
        min-height: auto !important;
    }

    /* Reset dashboard layout for print */
    .slms-main {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .slms-main-content {
        padding: 0 !important;
    }

    /* Table styling for print */
    .pg-editor table {
        page-break-inside: avoid;
    }

    .pg-editor th {
        background: #e0f2f1 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .pg-editor h2 {
        page-break-after: avoid;
        color: #004D40 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Page settings */
    @page {
        margin: 2cm;
    }
}
