/* Demo page styles - overrides styles.css body constraints */

.demo-mobile-guard {
    display: none;
}

@media (max-width: 768px) {
    .demo-mobile-guard {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: fixed;
        inset: 0;
        z-index: 200;
        background: var(--bg, #111);
        color: var(--text, #ccc);
        font-family: 'Space Grotesk', sans-serif;
        text-align: center;
        padding: 2rem;
    }

    .demo-mobile-guard p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .demo-mobile-guard a {
        color: var(--select, #217346);
        text-decoration: none;
        font-size: 0.9rem;
    }
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-image: none;
    max-width: none;
}

body {
    display: flex;
    flex-direction: column;
}

/* Demo header */
.demo-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--cell-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.demo-logo {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 500;
    background: linear-gradient(135deg, var(--text) 0%, var(--select) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.demo-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--select);
    background: var(--select-light);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(33, 115, 70, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.demo-preview-note {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.72rem;
    color: var(--muted);
    opacity: 0.8;
}

.demo-header-spacer {
    flex: 1;
}

.demo-feedback-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--select);
    text-decoration: none;
    transition: opacity 0.15s;
}

.demo-feedback-link:hover {
    opacity: 0.75;
}

.demo-header-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s;
}

.demo-header-link:hover {
    color: var(--select);
}

/* Split layout */
.demo-split {
    display: flex;
    flex: 1;
    min-height: 0;
}

.demo-grid-panel {
    flex: 4;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 2px solid var(--border);
}

.demo-chat-panel {
    flex: 6;
    min-width: 0;
}

.demo-chat-panel iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Formula bar */
.demo-formula-bar {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    background: var(--cell-bg);
    flex-shrink: 0;
    height: 30px;
}

.demo-cell-ref {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text);
    padding: 0 0.5rem;
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--row-header);
    border-right: 1px solid var(--border);
    user-select: none;
}

.demo-fx-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-style: italic;
    font-weight: 500;
    color: var(--muted);
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border);
    user-select: none;
}

.demo-formula-input {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    padding: 0 0.5rem;
    border: none;
    outline: none;
    background: var(--cell-bg);
    color: var(--text);
}

.demo-formula-input:focus {
    background: #fffef5;
}

.demo-formula-input.formula-bar-error {
    animation: formula-bar-shake 0.3s ease-out;
    background: #fef2f2 !important;
    color: #b91c1c;
}

@keyframes formula-bar-shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-4px); }
    30% { transform: translateX(4px); }
    50% { transform: translateX(-3px); }
    70% { transform: translateX(3px); }
    90% { transform: translateX(-2px); }
}

/* Grid container */
.demo-grid-container {
    flex: 1;
    overflow: auto;
    position: relative;
}

/* Status bar */
.demo-status-bar {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--row-header);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--muted);
    gap: 1rem;
}

.demo-status-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.demo-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #16a34a;
}

.demo-status-dot.loading {
    background: #f59e0b;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Grid table */
.grid-table {
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    width: max-content;
    table-layout: fixed;
}

.grid-table th,
.grid-table td {
    border: 1px solid var(--border);
    padding: 0;
    height: 24px;
    line-height: 24px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.grid-corner {
    width: 40px;
    min-width: 40px;
    background: var(--row-header);
    position: sticky;
    left: 0;
    z-index: 2;
}

.grid-col-header {
    width: 80px;
    min-width: 80px;
    background: linear-gradient(180deg, #f8f7f6 0%, #edebe9 100%);
    font-weight: 500;
    color: var(--muted);
    font-size: 0.7rem;
    text-align: center !important;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
    cursor: default;
}

.grid-row-header {
    width: 40px;
    min-width: 40px;
    background: linear-gradient(90deg, #f3f2f1 0%, #e8e6e4 100%);
    color: var(--muted);
    font-weight: 500;
    text-align: center !important;
    font-size: 0.7rem;
    border-right: 2px solid var(--border);
    position: sticky;
    left: 0;
    z-index: 1;
    user-select: none;
    cursor: default;
}


.grid-table td.grid-cell {
    width: 80px;
    min-width: 80px;
    background: var(--cell-bg);
    color: var(--text);
    padding: 0 6px;
    cursor: cell;
    outline: none;
    position: relative;
}

.grid-table td.grid-cell.cell-overflow {
    overflow: visible;
    z-index: 1;
}

.grid-table td.grid-cell.selected {
    box-shadow: inset 0 0 0 2px var(--select);
    background: var(--cell-bg);
    z-index: 2;
    position: relative;
}

.grid-table td.grid-cell.range-selected,
.grid-table td.grid-cell.range-selected:hover {
    background: rgba(33, 115, 70, 0.15);
}

.grid-cell.editing {
    box-shadow: inset 0 0 0 2px var(--select);
    background: #fff;
    cursor: text;
    overflow: visible;
}

.grid-cell.formula-cell {
    color: var(--select);
    font-weight: 600;
}

.grid-cell.formula-error {
    color: #b91c1c;
    font-weight: 400;
    overflow: visible;
    position: relative;
    z-index: 2;
}

.grid-cell .error-line-link {
    color: #b91c1c;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    white-space: nowrap;
}

.grid-cell .error-line-link:hover {
    color: #ef4444;
}

.grid-cell.cell-flash {
    animation: cell-flash 0.6s ease-out;
}

@keyframes cell-flash {
    0% { background: rgba(33, 115, 70, 0.15); }
    100% { background: var(--cell-bg); }
}

/* Demo toast banner */
.demo-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.demo-overlay.hiding {
    animation: toast-out 0.3s ease-in forwards;
}

.demo-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    background: var(--cell-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 480px;
    width: calc(100% - 2rem);
    font-family: 'Space Grotesk', sans-serif;
    animation: toast-in 0.3s ease-out;
}

.demo-toast.hiding {
    animation: toast-out 0.3s ease-in forwards;
}

.demo-toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--select-light);
    border: 1.5px solid var(--select);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--select);
    font-weight: 600;
    margin-top: 1px;
}

.demo-toast-body {
    flex: 1;
    min-width: 0;
}

.demo-toast-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.demo-toast-text {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.5;
}

.demo-toast-text p {
    margin: 0 0 0.5rem 0;
}

.demo-toast-text p:last-child {
    margin-bottom: 0;
}

.demo-toast-gotit {
    margin-top: 1.1rem;
    padding: 0.45rem 1.4rem;
    background: var(--select);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.demo-toast-gotit:hover {
    opacity: 0.85;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, -50%) translateY(-12px); }
    to   { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to   { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}

/* Responsive: stack vertically on narrow screens */
@media (max-width: 768px) {
    .demo-split {
        flex-direction: column;
    }

    .demo-grid-panel {
        flex: 1;
        border-right: none;
        border-bottom: 2px solid var(--border);
    }

    .demo-chat-panel {
        flex: 1;
    }
}
