/* =============================================
   Mobile Integration Playground Styles
   ============================================= */

:root {
    --playground-blue: #0771d0;
    --playground-blue-dark: #0a3761;
    --playground-green: #38bf84;
    --playground-green-dark: #2a9a68;
    --playground-orange: #ff6600;
    --playground-red: #dc3545;
    --playground-gray: #6c757d;
    --playground-gray-light: #f8f9fa;
    --playground-gray-dark: #343a40;
    --playground-border: #dee2e6;
    --playground-code-bg: #1e1e1e;
    --playground-code-text: #d4d4d4;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--playground-gray-dark);
    background-color: var(--playground-gray-light);
}

/* =============================================
   Playground Layout
   ============================================= */

.playground {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.playground-header {
    margin-bottom: 32px;
}

.back-link {
    display: inline-block;
    color: var(--playground-blue);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 12px;
}

.back-link:hover {
    text-decoration: underline;
}

.playground-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--playground-gray-dark);
    margin-bottom: 8px;
}

.playground-subtitle {
    font-size: 16px;
    color: var(--playground-gray);
    max-width: 800px;
}

.playground-note {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 14px;
    color: #856404;
    max-width: 900px;
}

.playground-note strong {
    color: #664d03;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--playground-gray-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* =============================================
   Configuration Section
   ============================================= */

.config-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--playground-border);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-item label {
    font-size: 12px;
    font-weight: 500;
    color: var(--playground-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-input {
    padding: 10px 12px;
    border: 1px solid var(--playground-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Roboto Mono', monospace;
    transition: border-color 0.2s;
}

.config-input:focus {
    outline: none;
    border-color: var(--playground-blue);
}

/* =============================================
   Step Sections
   ============================================= */

.step-section {
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--playground-border);
    overflow: hidden;
    transition: opacity 0.3s, box-shadow 0.3s;
}

.step-section.disabled {
    opacity: 0.6;
}

.step-section.active {
    box-shadow: 0 0 0 2px var(--playground-blue);
}

.step-section.completed {
    border-color: var(--playground-green);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--playground-gray-light);
    border-bottom: 1px solid var(--playground-border);
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--playground-blue);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-section.completed .step-number {
    background: var(--playground-green);
}

.step-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--playground-gray-dark);
    flex: 1;
}

.step-status {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.step-status[data-status="pending"] {
    background: var(--playground-gray-light);
    color: var(--playground-gray);
}

.step-status[data-status="loading"] {
    background: #fff3cd;
    color: #856404;
}

.step-status[data-status="success"] {
    background: #d4edda;
    color: #155724;
}

.step-status[data-status="error"] {
    background: #f8d7da;
    color: #721c24;
}

.step-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 300px;
}

@media (max-width: 1000px) {
    .step-content {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   Code Panel
   ============================================= */

.code-panel {
    background: var(--playground-code-bg);
    border-right: 1px solid var(--playground-border);
    display: flex;
    flex-direction: column;
}

@media (max-width: 1000px) {
    .code-panel {
        border-right: none;
        border-bottom: 1px solid var(--playground-border);
    }
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #444;
}

.code-label {
    font-size: 12px;
    color: #9d9d9d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-copy {
    padding: 4px 12px;
    font-size: 11px;
    background: transparent;
    color: #9d9d9d;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: #444;
    color: white;
}

.btn-copy.copied {
    background: var(--playground-green);
    border-color: var(--playground-green);
    color: white;
}

.code-block {
    flex: 1;
    margin: 0;
    padding: 16px;
    overflow: auto;
    font-family: 'Roboto Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--playground-code-text);
    white-space: pre;
}

.code-block code {
    font-family: inherit;
}

/* =============================================
   Result Panel
   ============================================= */

.result-panel {
    display: flex;
    flex-direction: column;
    background: white;
}

.result-header {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    background: var(--playground-gray-light);
    border-bottom: 1px solid var(--playground-border);
}

.btn-execute {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    background: var(--playground-green);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-execute:hover:not(:disabled) {
    background: var(--playground-green-dark);
}

.btn-execute:disabled {
    background: var(--playground-gray);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-execute .btn-icon {
    font-size: 12px;
}

.btn-execute.loading {
    background: var(--playground-orange);
}

.btn-execute.loading .btn-icon::before {
    content: '⏳';
}

.result-content {
    flex: 1;
    padding: 16px;
    overflow: auto;
}

.result-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--playground-gray);
    font-style: italic;
}

/* =============================================
   Result Display
   ============================================= */

.result-item {
    margin-bottom: 16px;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--playground-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.result-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    background: var(--playground-gray-light);
    padding: 8px 12px;
    border-radius: 4px;
    word-break: break-all;
    max-height: 300px;
    overflow: auto;
}

.result-value.success {
    background: #d4edda;
    color: #155724;
}

.result-value.error {
    background: #f8d7da;
    color: #721c24;
}

.result-value.truncated {
    max-height: 400px;
    white-space: pre-wrap;
    font-size: 11px;
}

/* =============================================
   Network Request Display
   ============================================= */

.network-request {
    background: var(--playground-gray-light);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.network-method {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
}

.network-method.get {
    background: #61affe;
    color: white;
}

.network-method.post {
    background: #49cc90;
    color: white;
}

.network-url {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    word-break: break-all;
}

.network-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

.network-status.status-200, .network-status.status-204 {
    background: #d4edda;
    color: #155724;
}

.network-status.status-302, .network-status.status-301 {
    background: #fff3cd;
    color: #856404;
}

.network-status.status-error {
    background: #f8d7da;
    color: #721c24;
}

/* =============================================
   Preview Section
   ============================================= */

.preview-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    border: 2px solid var(--playground-blue);
    box-shadow: 0 4px 12px rgba(7, 113, 208, 0.15);
}

.preview-section.rendered {
    border-color: var(--playground-green);
    box-shadow: 0 4px 12px rgba(56, 191, 132, 0.15);
}

.preview-description {
    color: var(--playground-gray);
    font-size: 14px;
    margin-bottom: 12px;
}

.preview-events-info {
    background: #e7f3ff;
    border: 1px solid #b3d7ff;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--playground-blue-dark);
}

.preview-events-info ul {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.preview-events-info li {
    margin-bottom: 4px;
}

.preview-events-info code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
}

.preview-viewability-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #856404;
    line-height: 1.6;
}

.preview-viewability-note code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
}

.preview-viewability-note small {
    display: block;
    margin-top: 6px;
    opacity: 0.85;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.btn-render {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    background: var(--playground-blue);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-render:hover:not(:disabled) {
    background: var(--playground-blue-dark);
    transform: translateY(-1px);
}

.btn-render:disabled {
    background: var(--playground-gray);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-render.rendered {
    background: var(--playground-green);
}

.btn-render.rendered:hover {
    background: var(--playground-green-dark);
}

.render-hint {
    font-size: 13px;
    color: var(--playground-gray);
    font-style: italic;
}

.render-hint.success {
    color: var(--playground-green);
    font-style: normal;
    font-weight: 500;
}

.preview-container {
    background: var(--playground-gray-light);
    border-radius: 8px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Debug Badge */
.step-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-badge {
    background: #e9ecef;
    color: var(--playground-gray);
}

.preview-ad {
    width: 100%;
    max-width: 400px;
}

.preview-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--playground-gray);
    font-style: italic;
    border: 2px dashed var(--playground-border);
    border-radius: 8px;
}

/* Ad Button Preview (same styles as brand-store.ejs) */
.preview-ad-button {
    display: block;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--playground-border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--playground-gray-dark);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.preview-ad-button:hover {
    border-color: var(--playground-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-ad-label {
    display: block;
    font-size: 9px;
    color: var(--playground-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.preview-ad-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.preview-shop-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--playground-orange);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
}

.preview-price {
    font-weight: 700;
}

/* =============================================
   Network Log Section
   ============================================= */

.network-log-section {
    background: var(--playground-code-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.network-log-section .section-title {
    color: #d4d4d4;
}

.btn-clear {
    padding: 4px 12px;
    font-size: 11px;
    background: transparent;
    color: #9d9d9d;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #444;
    color: white;
}

.network-log {
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-empty {
    color: #666;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.log-entry {
    padding: 8px 12px;
    border-bottom: 1px solid #333;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: #666;
    flex-shrink: 0;
}

.log-method {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.log-method.get {
    background: #61affe;
    color: white;
}

.log-method.post {
    background: #49cc90;
    color: white;
}

.log-url {
    color: #9cdcfe;
    word-break: break-all;
    flex: 1;
}

.log-status {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.log-status.success {
    background: #155724;
    color: #d4edda;
}

.log-status.redirect {
    background: #856404;
    color: #fff3cd;
}

.log-status.error {
    background: #721c24;
    color: #f8d7da;
}

.log-body {
    width: 100%;
    color: #ce9178;
    padding: 8px;
    background: #2a2a2a;
    border-radius: 4px;
    margin-top: 4px;
    white-space: pre-wrap;
    max-height: 100px;
    overflow: auto;
}

/* =============================================
   Footer
   ============================================= */

.playground-footer {
    background: white;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--playground-border);
    text-align: center;
    color: var(--playground-gray);
    font-size: 14px;
}

.playground-footer strong {
    color: var(--playground-gray-dark);
}

/* =============================================
   Utilities
   ============================================= */

.hidden {
    display: none !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.code-panel ::-webkit-scrollbar-track,
.network-log ::-webkit-scrollbar-track {
    background: #2a2a2a;
}

.code-panel ::-webkit-scrollbar-thumb,
.network-log ::-webkit-scrollbar-thumb {
    background: #555;
}

.code-panel ::-webkit-scrollbar-thumb:hover,
.network-log ::-webkit-scrollbar-thumb:hover {
    background: #666;
}
