/* ============================================================
   Calculator Page — Pixel-precise match to engineeringtoolkit.info
   ============================================================ */

/* --- Page bg override --- */
.tk-main {
    background: #f8fafc;
    padding: 2rem 2.5rem;
}

/* --- Page header --- */
.calc-page-header {
    margin-bottom: 2rem;
}
.calc-page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.35rem 0;
    letter-spacing: -0.025em;
    font-family: 'Inter', sans-serif;
}
.calc-page-header p {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

/* --- Layout --- */
.calc-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

/* --- Left: Calculator card --- */
.calc-main {
    flex: 1;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.07);
}

/* --- Display --- */
.calc-display-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    text-align: right;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.calc-expression {
    color: #94a3b8;
    font-size: 0.95rem;
    min-height: 1.4rem;
    font-family: ui-monospace, 'Courier New', monospace;
    overflow-x: auto;
    white-space: nowrap;
}
.calc-result {
    color: #0f172a;
    font-size: 2.75rem;
    font-weight: 700;
    font-family: ui-monospace, 'Courier New', monospace;
    overflow-x: auto;
    white-space: nowrap;
    line-height: 1.15;
}

/* --- Button grid --- */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
}

/* --- Base button --- */
.calc-btn {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #334155;
    border-radius: 8px;
    padding: 0.8rem 0.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
}
.calc-btn:hover {
    background: #f1f5f9;
}
.calc-btn:active {
    transform: scale(0.95);
}

/* --- Function buttons (grey border) --- */
.fn-btn {
    background: #ffffff;
    color: #334155;
}
.fn-btn:hover {
    background: #f1f5f9;
}

/* --- Orange-tinted fn buttons (ln, log like reference) --- */
.orange-fn {
    color: #d97706;
}

/* --- Number buttons (blue) --- */
.num-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    font-weight: 600;
    font-size: 1.1rem;
}
.num-btn:hover {
    background: #1d4ed8;
}

/* --- Equals button (dark navy) --- */
.eq-btn {
    background: #1e3a8a;
    color: #ffffff;
    border: none;
    font-weight: 700;
    font-size: 1.1rem;
}
.eq-btn:hover {
    background: #1e40af;
}

/* --- AC button (red/destructive) --- */
.ac-btn {
    background: #ef4444;
    color: #ffffff;
    border: none;
    font-weight: 600;
}
.ac-btn:hover {
    background: #dc2626;
}

/* --- Memory button (neutral grey) --- */
.mem-btn {
    background: #e5e7eb;
    color: #1f2937;
    border: none;
    font-size: 0.875rem;
}
.mem-btn:hover {
    background: #d1d5db;
}

/* --- span-4 helper (+ button) --- */
.span4 {
    grid-column: span 4;
}

/* --- Keyboard hint --- */
.calc-hints {
    margin-top: 1.25rem;
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
}

/* ============================================================
   Right: Formula Sidebar
   ============================================================ */
.formula-sidebar {
    width: 360px;
    flex-shrink: 0;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.07);
}
.formula-sidebar h3 {
    margin: 0 0 1.25rem 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #0f172a;
}

/* Form groups */
.form-group {
    margin-bottom: 1.1rem;
}
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    margin-bottom: 0.4rem;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #0f172a;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 40px;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Input with icon */
.input-icon-wrap {
    position: relative;
}
.input-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.8rem;
    pointer-events: none;
}
.icon-input {
    padding-left: 34px !important;
}

/* Tags row */
.tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.tag {
    background: #f1f5f9;
    color: #475569;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid #e2e8f0;
}

/* Favorite / Study sheet buttons */
.formula-action-btns {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.sec-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}
.sec-btn:hover {
    background: #f8fafc;
}
.sec-btn-full {
    flex: 1;
    justify-content: center;
}

/* Formula display box */
.formula-display-group {
    position: relative;
}
.formula-display-box {
    padding: 1.25rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2rem;
    overflow-x: auto;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.formula-help-btn {
    position: absolute;
    bottom: -12px;
    right: -12px;
    background: #2563eb;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* Description */
.formula-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.55;
    margin: 1.25rem 0 1.25rem 0;
}

/* Dynamic input rows */
.formula-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.formula-input-row label {
    flex: 1;
    font-size: 0.875rem;
    color: #334155;
    font-weight: 500;
    margin-bottom: 0;
}
.formula-input-row input {
    width: 100px;
    padding: 0.45rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: right;
    height: 36px;
    font-size: 0.875rem;
    box-sizing: border-box;
}
.formula-input-row span {
    width: 28px;
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: left;
}

/* Calculate button */
.btn-calculate {
    width: 100%;
    background: #2563eb;
    color: #ffffff;
    border: none;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    margin-top: 1.25rem;
    transition: background 0.15s;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}
.btn-calculate:hover {
    background: #1d4ed8;
}

/* Result box */
.formula-result-box {
    margin-top: 1.25rem;
    padding: 0.9rem 1.1rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1e3a8a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.result-label {
    font-size: 0.875rem;
    font-weight: 500;
}
.result-value {
    font-size: 1rem;
    font-weight: 700;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
    .calc-layout {
        flex-direction: column;
    }
    .formula-sidebar {
        width: 100%;
    }
}
@media (max-width: 600px) {
    .tk-main {
        padding: 1rem;
    }
    .calc-page-header h1 {
        font-size: 1.5rem;
    }
    .calc-grid {
        gap: 0.3rem;
    }
    .calc-btn {
        padding: 0.65rem 0;
        font-size: 0.875rem;
        min-height: 40px;
    }
    .calc-result {
        font-size: 2rem;
    }
}
