/* Scientific Calculator Specific Styles */

/* Calculator wrapper adjustments */
.scientific-calc {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

/* Calculator Display */
.calc-display {
    background: linear-gradient(to bottom, #1a1a2e, #16213e);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    text-align: right;
    overflow: hidden;
}

.calc-expression {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    min-height: 20px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.calc-result {
    font-size: 36px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-result.error {
    color: #f87171;
    font-size: 18px;
}

/* Angle Toggle (DEG/RAD) */
.angle-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--color-bg-body);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.angle-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.angle-btn:hover {
    color: var(--color-text-primary);
}

.angle-btn.active {
    background: var(--color-primary);
    color: #ffffff;
}

/* Memory Indicator */
.memory-indicator {
    position: absolute;
    top: 76px;
    right: 32px;
    background: var(--color-accent);
    color: var(--color-text-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Calculator Buttons Grid */
.calc-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

/* Base button style */
.calc-btn {
    padding: 14px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.calc-btn:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calc-btn:active {
    transform: scale(0.97);
}

/* Number buttons */
.calc-btn.num {
    background: #f8fafc;
    font-size: 18px;
    font-weight: 600;
}

.calc-btn.num:hover {
    background: #f1f5f9;
}

/* Zero button spans 2 columns on last row */
.calc-btn.zero {
    /* Handled in grid layout */
}

/* Operator buttons */
.calc-btn.operator {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
    font-size: 20px;
}

.calc-btn.operator:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

/* Equals button */
.calc-btn.equals {
    background: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
    font-size: 22px;
    font-weight: 700;
}

.calc-btn.equals:hover {
    background: #15803d;
    border-color: #15803d;
}

/* Function buttons */
.calc-btn.func {
    background: #e0f2fe;
    color: var(--color-primary);
    border-color: #bae6fd;
    font-size: 13px;
}

.calc-btn.func:hover {
    background: #bae6fd;
}

/* Clear buttons */
.calc-btn.clear {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.calc-btn.clear:hover {
    background: #fecaca;
}

/* Parentheses buttons */
.calc-btn.paren {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
    font-size: 18px;
}

.calc-btn.paren:hover {
    background: #dcfce7;
}

/* Superscript in buttons */
.calc-btn sup {
    font-size: 10px;
    vertical-align: super;
    line-height: 0;
}

/* History Panel */
.history-panel {
    margin-top: 16px;
    background: var(--color-bg-body);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.history-toggle {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}

.history-toggle::-webkit-details-marker {
    display: none;
}

.history-toggle::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--color-text-secondary);
    border-bottom: 2px solid var(--color-text-secondary);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.history-panel[open] .history-toggle::after {
    transform: rotate(-135deg);
}

.history-content {
    padding: 0 16px 16px;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.history-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.history-item:last-child {
    border-bottom: none;
}

.history-expression {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.history-result {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.history-empty {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
    padding: 16px 0;
}

.history-clear {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-clear:hover {
    border-color: #dc2626;
    color: #dc2626;
}

/* Share button group styling */
.scientific-calc .button-group {
    margin-top: 16px;
}

.scientific-calc .share-trigger-btn {
    max-width: 200px;
    margin: 0 auto;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .scientific-calc {
        max-width: 100%;
    }

    .calc-buttons {
        gap: 4px;
    }

    .calc-btn {
        padding: 12px 4px;
        font-size: 13px;
        min-height: 40px;
    }

    .calc-btn.num {
        font-size: 16px;
    }

    .calc-btn.operator {
        font-size: 18px;
    }

    .calc-btn.equals {
        font-size: 20px;
    }

    .calc-btn.func {
        font-size: 11px;
    }

    .calc-result {
        font-size: 28px;
    }

    .calc-expression {
        font-size: 12px;
    }

    .memory-indicator {
        top: 60px;
        right: 24px;
    }
}

@media (max-width: 360px) {
    .calc-buttons {
        gap: 3px;
    }

    .calc-btn {
        padding: 10px 2px;
        font-size: 12px;
        min-height: 36px;
    }

    .calc-btn.num {
        font-size: 14px;
    }

    .calc-btn.func {
        font-size: 10px;
    }

    .calc-btn sup {
        font-size: 8px;
    }
}

/* Touch-friendly adjustments */
@supports (-webkit-touch-callout: none) {
    .calc-btn {
        min-height: 44px;
    }
}

/* Print styles */
@media print {
    .calc-buttons,
    .angle-toggle,
    .history-panel,
    .button-group {
        display: none !important;
    }

    .calc-display {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .calc-result {
        color: #000 !important;
    }

    .calc-expression {
        color: #666 !important;
    }
}
