/* ========================================
   SmartCalc - Main Stylesheet
   ======================================== */

/* ---- Design Tokens ---- */
:root {
    --ink: #1A2B3C;
    --mist: #F5F7FA;
    --pure: #FFFFFF;
    --success: #10B981;
    --danger: #EF4444;
    --muted: #6B7280;
    --border: #E5E7EB;
    --radius-card: 16px;
    --radius-btn: 8px;
    --radius-input: 8px;
    --shadow-card: 0 1px 3px rgba(26,43,60,0.08);
    --shadow-card-hover: 0 8px 30px rgba(26,43,60,0.12);
    --shadow-input-focus: 0 0 0 3px rgba(15,118,110,0.15);
    --transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ---- Global ---- */
* { box-sizing: border-box; }

body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
    color: var(--ink);
    background-color: var(--pure);
    line-height: 1.6;
    padding-top: 64px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none !important; color: inherit; transition: var(--transition); }
a:hover { text-decoration: none !important; }

/* ---- Navbar ---- */
#mainNav {
    height: 64px;
    background: var(--pure) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
    z-index: 1030;
}

#mainNav.nav-scrolled {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: 700;
    font-size: 20px;
    color: var(--ink) !important;
    letter-spacing: -0.5px;
}

.nav-link {
    font-weight: 500;
    font-size: 15px;
    color: var(--muted) !important;
    padding: 8px 16px !important;
    position: relative;
}

.nav-item.active .nav-link,
.nav-link:hover {
    color: var(--ink) !important;
}

.nav-item.active .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background: #0F766E;
}

.navbar-toggler {
    border: none;
    padding: 4px 8px;
}

.navbar-toggler:focus { outline: none; box-shadow: none; }

/* ---- Sections ---- */
.section { padding: 80px 0; }
.section-white { background: var(--pure); }
.section-gray { background: var(--mist); }

.section-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.section-desc {
    font-size: 16px;
    color: var(--muted);
}

/* ---- Hero Section ---- */
.hero-section {
    padding: 100px 0 80px;
    background: var(--mist);
    position: relative;
    overflow: hidden;
}

.hero-badge {
    display: inline-block;
    background: #0F766E;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 16px;
    border-radius: 100px;
    margin-bottom: 20px;
}

.hero-title {
    font-size: 52px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ink);
    letter-spacing: -1.5px;
    margin-bottom: 20px;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--muted);
    margin-bottom: 32px;
    max-width: 480px;
}

.hero-buttons { margin-bottom: 40px; }

.hero-btn-primary {
    background: #0F766E !important;
    border-color: #0F766E !important;
    color: #fff !important;
    padding: 16px 32px !important;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-btn) !important;
    box-shadow: 0 4px 12px rgba(15,118,110,0.25);
    margin-right: 12px;
    margin-bottom: 8px;
}

.hero-btn-primary:hover {
    background: #0D5C56 !important;
    border-color: #0D5C56 !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15,118,110,0.35);
}

.hero-btn-outline {
    border: 2px solid var(--border) !important;
    color: var(--ink) !important;
    padding: 16px 32px !important;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-btn) !important;
    margin-bottom: 8px;
}

.hero-btn-outline:hover {
    border-color: #0F766E !important;
    color: #0F766E !important;
}

.hero-stats {
    display: flex;
    gap: 32px;
}

.stat-item { text-align: center; }

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hero formula background */
.hero-formula-bg {
    position: relative;
    height: 400px;
}

.hero-formula-text {
    position: absolute;
    font-size: 72px;
    font-weight: 700;
    color: var(--ink);
    opacity: 0.08;
    font-family: "KaTeX_Math", "Times New Roman", serif;
    white-space: nowrap;
}

.hero-formula-text:nth-child(1) { top: 5%; left: 10%; }
.hero-formula-text:nth-child(2) { top: 30%; left: 15%; }
.hero-formula-text:nth-child(3) { top: 55%; left: 50%; }
.hero-formula-text:nth-child(4) { top: 75%; left: 20%; }

/* Floating card */
.hero-float-card {
    position: absolute;
    right: 40px;
    bottom: 60px;
    width: 260px;
    background: var(--pure);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card-hover);
    overflow: hidden;
    animation: floatCard 3s ease-in-out infinite;
}

@keyframes floatCard {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.float-card-header {
    height: 4px;
    background: #0F766E;
}

.float-card-body { padding: 20px; }

.float-card-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #0F766E;
    background: rgba(15,118,110,0.1);
    padding: 2px 10px;
    border-radius: 100px;
    margin-bottom: 8px;
}

.float-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
}

.float-card-formula {
    font-size: 22px;
    color: var(--muted);
    margin-bottom: 8px;
    text-align: center;
}

.float-card-desc {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.float-card-link {
    font-size: 13px;
    font-weight: 600;
    color: #0F766E;
}

/* ---- Formula Cards ---- */
.formula-card-link { display: block; }

.formula-card {
    background: var(--pure);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: var(--transition);
    height: 100%;
}

.formula-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

.card-color-bar {
    height: 4px;
    width: 100%;
}

.formula-card .card-body {
    padding: 24px;
}

.card-category-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 100px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 12px;
}

.card-latex {
    font-size: 24px;
    text-align: center;
    margin: 16px 0;
    min-height: 36px;
    color: var(--ink);
}

.card-desc {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 16px;
    min-height: 42px;
}

.card-footer-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.card-btn {
    display: inline-block;
    padding: 6px 16px;
    border: 1.5px solid;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.formula-card:hover .card-btn {
    background: var(--card-color, #0F766E);
    color: #fff !important;
    border-color: var(--card-color, #0F766E) !important;
}

.card-param-count {
    font-size: 12px;
    color: var(--muted);
}

/* ---- Feature Cards ---- */
.feature-card {
    background: var(--pure);
    border-radius: var(--radius-card);
    padding: 32px;
    height: 100%;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

.feature-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.feature-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
}

.feature-desc {
    font-size: 14px;
    color: var(--muted);
    margin: 0;
}

/* ---- Category Pills ---- */
.category-pill-link { display: block; }

.category-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    border-radius: 100px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    text-align: center;
}

.category-pill:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.category-count {
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.8;
    background: rgba(255,255,255,0.25);
    padding: 1px 8px;
    border-radius: 100px;
}

/* ---- CTA Section ---- */
.cta-section {
    padding: 100px 0;
    background: var(--ink);
    color: #fff;
    text-align: center;
}

.cta-title {
    font-size: 36px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 16px;
}

.cta-desc {
    font-size: 18px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 32px;
}

.cta-btn {
    background: #fff !important;
    color: var(--ink) !important;
    font-weight: 600;
    padding: 16px 40px !important;
    border-radius: var(--radius-btn) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* ---- Page Header ---- */
.page-header {
    padding: 48px 0;
    background: var(--mist);
}

.page-title {
    font-size: 36px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.page-desc {
    font-size: 16px;
    color: var(--muted);
    margin: 0;
}

/* ---- Filter Bar ---- */
.filter-bar {
    background: var(--pure);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    z-index: 1020;
    top: 64px;
}

.filter-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-buttons-wrapper {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-btn {
    padding: 8px 18px;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    background: var(--pure);
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-btn:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.filter-btn.active {
    background: #0F766E;
    color: #fff;
    border-color: #0F766E;
}

.filter-search { flex-shrink: 0; }

.search-input-wrapper {
    position: relative;
    width: 240px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-input);
    font-size: 14px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: #0F766E;
    box-shadow: var(--shadow-input-focus);
}

.filter-count {
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--muted);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* ---- Formula Detail Header ---- */
.formula-header {
    padding: 32px 0 48px;
}

.formula-breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 20px;
    font-size: 14px;
}

.formula-breadcrumb a { color: var(--muted); }
.formula-breadcrumb a:hover { color: var(--ink); }

.formula-category-tag {
    display: inline-block;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 100px;
    margin-bottom: 12px;
}

.formula-name {
    font-size: 36px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -1px;
    margin-bottom: 16px;
}

.formula-latex-large {
    font-size: 32px;
    text-align: center;
    margin: 24px 0;
    color: var(--ink);
}

.formula-desc {
    font-size: 16px;
    color: var(--muted);
    max-width: 600px;
}

/* ---- Calculation Form ---- */
.calc-card {
    background: var(--pure);
    border-radius: var(--radius-card);
    padding: 32px;
    box-shadow: var(--shadow-card);
}

.calc-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 24px;
}

.calc-input-row {
    margin-bottom: 20px;
}

.calc-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ink);
    flex-wrap: wrap;
}

.label-name { }

.label-symbol {
    font-style: italic;
    color: var(--muted);
}

.label-unit {
    color: var(--muted);
    font-size: 13px;
}

.label-required {
    color: var(--danger);
    font-size: 14px;
}

.calc-input {
    height: 48px;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-input);
    font-size: 15px;
    transition: var(--transition);
}

.calc-input:focus {
    border-color: #0F766E;
    box-shadow: var(--shadow-input-focus);
}

.calc-input.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}

.calc-help {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

.calc-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.btn-calculate {
    flex: 1;
    min-width: 160px;
    height: 56px;
    color: #fff !important;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-btn);
    transition: var(--transition);
}

.btn-calculate:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    opacity: 0.9;
}

.btn-calculate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-reset {
    padding: 12px 24px;
    color: var(--muted) !important;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-btn);
    font-weight: 500;
    transition: var(--transition);
}

.btn-reset:hover {
    border-color: var(--muted);
    color: var(--ink) !important;
}

/* ---- Result Panel ---- */
.result-panel {
    background: #F0FDF4;
    border-left: 4px solid var(--success);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.result-icon { font-size: 20px; }

.result-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
}

.result-value {
    font-size: 42px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -1px;
    word-break: break-all;
}

.result-unit {
    font-size: 18px;
    color: var(--muted);
    margin-top: 4px;
}

.result-steps {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(16,185,129,0.2);
    font-size: 15px;
    color: var(--muted);
    overflow-x: auto;
}

.result-actions {
    margin-top: 16px;
}

/* ---- Error Panel ---- */
.error-panel {
    background: #FEF2F2;
    border-left: 4px solid var(--danger);
    border-radius: 12px;
    padding: 20px 28px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-icon {
    font-size: 20px;
    color: var(--danger);
    flex-shrink: 0;
}

.error-message {
    color: var(--danger);
    font-size: 15px;
}

/* ---- Chart Panel ---- */
.chart-panel {
    background: var(--pure);
    border-radius: var(--radius-card);
    padding: 24px;
    box-shadow: var(--shadow-card);
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 16px;
}

.chart-container {
    height: 320px;
    position: relative;
}

/* ---- Result Placeholder ---- */
.result-placeholder {
    background: var(--pure);
    border-radius: var(--radius-card);
    padding: 60px 32px;
    box-shadow: var(--shadow-card);
    text-align: center;
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.placeholder-text {
    font-size: 15px;
    color: var(--muted);
    line-height: 1.8;
    margin: 0;
}

/* ---- Formula Info ---- */
.info-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 20px;
}

.info-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--ink);
}

.table-variables {
    font-size: 14px;
}

.table-variables th {
    border-top: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-variables td {
    vertical-align: middle;
    padding: 12px 16px;
}

.var-symbol {
    font-family: "KaTeX_Math", "Times New Roman", serif;
    font-style: italic;
}

/* ---- Related Formulas ---- */
.related-card {
    display: flex;
    background: var(--pure);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
    transition: var(--transition);
}

.related-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-card-hover);
}

.related-bar {
    width: 4px;
    flex-shrink: 0;
}

.related-body { padding: 16px; }

.related-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

.related-latex {
    font-size: 16px;
    color: var(--muted);
}

/* ---- Footer ---- */
.site-footer {
    background: var(--ink);
    color: #fff;
    padding: 60px 0 24px;
}

.footer-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 16px;
}

.footer-desc {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
    margin-bottom: 8px;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li { margin-bottom: 8px; }

.footer-links a {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #fff;
}

.footer-divider {
    border-color: rgba(255,255,255,0.1);
    margin: 32px 0 20px;
}

.footer-copyright {
    font-size: 13px;
    color: rgba(255,255,255,0.4);
}

/* ---- Toast Notification ---- */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--ink);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-btn);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ---- Animations ---- */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* ---- Responsive ---- */
@media (max-width: 1023px) {
    .hero-title { font-size: 40px; }
    .section { padding: 60px 0; }
    .hero-section { padding: 80px 0 60px; }
    .cta-section { padding: 80px 0; }
    .cta-title { font-size: 28px; }
}

@media (max-width: 767px) {
    body { padding-top: 56px; }
    
    #mainNav { height: 56px; }
    
    .hero-title { font-size: 32px; }
    .hero-subtitle { font-size: 16px; }
    .hero-stats { gap: 20px; }
    .stat-number { font-size: 22px; }
    
    .section { padding: 48px 0; }
    .hero-section { padding: 60px 0 48px; }
    
    .section-title { font-size: 24px; }
    
    .hero-buttons { display: flex; flex-direction: column; }
    .hero-btn-primary { margin-right: 0; width: 100%; text-align: center; }
    .hero-btn-outline { width: 100%; text-align: center; }
    
    .page-title { font-size: 28px; }
    
    .filter-content { flex-direction: column; align-items: stretch; }
    .filter-buttons-wrapper { 
        flex-wrap: nowrap; 
        overflow-x: auto; 
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .search-input-wrapper { width: 100%; }
    
    .formula-latex-large { font-size: 24px; }
    .formula-name { font-size: 28px; }
    
    .calc-actions { flex-direction: column; }
    .btn-calculate { width: 100%; }
    
    .result-value { font-size: 32px; }
    
    .chart-container { height: 280px; }
    
    .cta-section { padding: 60px 0; }
    .cta-title { font-size: 24px; }
    .cta-btn { width: 100%; }
}

@media (max-width: 479px) {
    .hero-title { font-size: 28px; }
    .hero-badge { font-size: 11px; padding: 5px 12px; }
    .hero-subtitle { font-size: 15px; }
    
    .formula-card .card-body { padding: 20px; }
    .card-title { font-size: 18px; }
    .card-latex { font-size: 20px; }
    
    .feature-card { padding: 24px; }
    .feature-icon { font-size: 36px; }
    
    .calc-card { padding: 24px; }
    .result-panel { padding: 20px; }
    
    .footer-title { font-size: 15px; }
    .footer-desc { font-size: 13px; }
}
