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

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

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

/* Web header */
.web-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;
}

.web-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;
}

.web-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;
}

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

.web-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;
}

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

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

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

/* Split layout */
.web-split {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

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

.web-chat-panel {
    flex: 6;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

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

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

.web-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;
}

.web-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;
}

.web-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);
}

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

.web-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 */
.web-grid-container {
    flex: 1;
    overflow: auto;
    position: relative;
}

/* Status bar */
.web-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;
}

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

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

.web-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.formula-cell {
    color: var(--select);
    font-weight: 600;
}

.grid-cell.spill-cell {
    color: var(--select);
}

.grid-cell.spill-border-top {
    border-top: 2px dashed var(--select);
}

.grid-cell.spill-border-bottom {
    border-bottom: 2px dashed var(--select);
}

.grid-cell.spill-border-left {
    border-left: 2px dashed var(--select);
}

.grid-cell.spill-border-right {
    border-right: 2px dashed var(--select);
}

.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); }
}

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

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

.web-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;
}

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

.web-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;
}

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

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

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

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

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

.web-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;
    outline: none;
    transition: opacity 0.15s;
}

.web-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: show only the add-in on mobile */
@media (max-width: 768px) {
    .web-grid-panel {
        display: none;
    }

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

    .web-header {
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .web-feedback-link {
        display: none;
    }
}
