﻿/* ==========================================================
   Calculator styles - modern flat design
   ========================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 460px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: #fff;
    font-size: 1.8rem;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* ===== Calculator main card ===== */
.calculator {
    background: #1e1e2e;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ===== Display area ===== */
.display {
    background: #2a2a3d;
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 18px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    overflow: hidden;
}

.expression {
    color: #a0a0b8;
    font-size: 1.1rem;
    font-family: "SF Mono", "Consolas", "Monaco", monospace;
    word-break: break-all;
    text-align: right;
    max-height: 48px;
    overflow-y: auto;
}

.result {
    color: #ffffff;
    font-size: 2rem;
    font-weight: 600;
    font-family: "SF Mono", "Consolas", "Monaco", monospace;
    word-break: break-all;
    text-align: right;
    margin-top: 6px;
}

.result.error {
    color: #ff6b6b;
    font-size: 1.3rem;
    font-weight: 500;
}

/* ===== Button panel ===== */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 18px 0;
    font-size: 1.2rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    color: #fff;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.94);
}

.btn-num {
    background: #3a3a4f;
}

.btn-num:hover {
    background: #464660;
}

.btn-op {
    background: #ff9f43;
}

.btn-op:hover {
    background: #ffa854;
}

.btn-func {
    background: #546e7a;
}

.btn-func:hover {
    background: #607d8b;
}

.btn-clear {
    background: #ef5350;
}

.btn-clear:hover {
    background: #ff6b68;
}

.btn-equal {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.btn-equal:hover {
    filter: brightness(1.1);
}

.btn.zero {
    grid-column: span 2;
}

/* ===== History section ===== */
.history-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    margin-top: 24px;
    padding: 18px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.history-header h2 {
    font-size: 1.1rem;
    color: #333;
}

.btn-clear-all {
    background: #ef5350;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-clear-all:hover {
    background: #d32f2f;
}

.btn-clear-all:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.history-list {
    max-height: 320px;
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 30px 0;
    font-size: 0.9rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: #f5f5fa;
    transition: background 0.15s ease;
}

.history-item:hover {
    background: #ebebf3;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-expr {
    font-family: "SF Mono", "Consolas", "Monaco", monospace;
    font-size: 0.95rem;
    color: #555;
    word-break: break-all;
}

.history-result {
    font-family: "SF Mono", "Consolas", "Monaco", monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: #11998e;
    margin-top: 2px;
}

.history-time {
    font-size: 0.72rem;
    color: #aaa;
    margin-top: 2px;
}

.history-del {
    background: none;
    border: none;
    color: #ef5350;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    margin-left: 10px;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.history-del:hover {
    background: rgba(239, 83, 80, 0.1);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.75);
    margin-top: 18px;
    line-height: 1.5;
}

/* ===== Loading state ===== */
.loading::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    body { padding: 10px; }
    .calculator { padding: 14px; border-radius: 16px; }
    .btn { padding: 16px 0; font-size: 1.1rem; border-radius: 10px; }
    .result { font-size: 1.6rem; }
    h1 { font-size: 1.5rem; }
}