/*
Theme Name: MatrixPro
Theme URI: https://example.com/matrixpro
Author: Gemini AI
Description: Theme chuyên dụng cho công cụ Toán học, tối ưu giao diện Plugin Matrix Toolkit.
Version: 1.0
*/

:root {
    --primary: #2563eb;       /* Xanh khoa học */
    --secondary: #0f172a;     /* Đen than chì */
    --bg-body: #f8fafc;       /* Xám nhạt nền nã */
    --text-main: #334155;
    --border: #e2e8f0;
    --container-width: 1100px;
}

/* --- RESET & BASE --- */
* { box-sizing: border-box; }
body {
    margin: 0; padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    
    /* [MỚI] Áp dụng nền lưới cho TOÀN BỘ TRANG */
    background-color: var(--bg-body);
    background-image: 
        linear-gradient(var(--border) 1.5px, transparent 1.5px), 
        linear-gradient(90deg, var(--border) 1.5px, transparent 1.5px);
    background-size: 40px 40px; 
}

a { text-decoration: none; color: var(--primary); transition: 0.2s; }
a:hover { color: var(--secondary); }

/* --- LAYOUT --- */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* --- HEADER --- */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    position: sticky; top: 0; z-index: 1000;
}
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.site-title { font-size: 1.5rem; font-weight: 800; color: var(--secondary); margin: 0; }
.site-title span { color: var(--primary); }
.main-nav ul { display: flex; gap: 20px; list-style: none; margin: 0; padding: 0; }
.main-nav a { font-weight: 600; color: var(--text-main); font-size: 14px; }

/* --- HERO SECTION (ĐÃ TỐI ƯU GIAO DIỆN) --- */
.page-hero {
    position: relative;
    text-align: center;
    padding: 80px 20px 60px;
    
    /* [CŨ] BỎ background-image lưới ở đây để nền body hiện ra */
    background-color: transparent; 
    
    /* Thêm một lớp nền mỏng cho độ tương phản */
    box-shadow: inset 0 0 50px rgba(255, 255, 255, 0.5); 
    
    border-bottom: 1px solid #cbd5e1;
}

/* Hiệu ứng mờ dần ở đáy Hero để hòa trộn vào nội dung */
.page-hero::after {
    content: "";
    position: absolute; bottom: 0; left: 0; width: 100%; height: 60px;
    background: linear-gradient(to bottom, rgba(248,250,252,0), var(--bg-body));
    pointer-events: none;
}

.page-hero .container {
    position: relative; z-index: 2;
}

/* Tiêu đề chính (Typography Optimization) */
.page-hero h1 { 
    font-size: 3rem; 
    font-weight: 800; 
    margin: 0 0 15px; 
    letter-spacing: -0.03em;
    line-height: 1.2;
    
    background: -webkit-linear-gradient(45deg, #0f172a, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Dòng mô tả phụ */
.page-hero p { 
    font-size: 1.2rem; 
    color: #64748b; 
    max-width: 700px; 
    margin: 0 auto; 
    font-weight: 500;
    /* Giữ nền trắng nhẹ cho chữ nổi bật trên nền lưới */
    background: #fff; 
    display: inline-block; 
    padding: 5px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

/* --- CONTENT AREA --- */
.site-content { padding: 40px 0 80px; }

/* ============================================================
   PLUGIN INTEGRATION (GHI ĐÈ VÀ LÀM ĐẸP)
   ============================================================ */
#mtl-app { 
    border: none !important; 
    box-shadow: 0 20px 40px -5px rgba(0,0,0,0.08) !important; 
    border-radius: 20px !important; 
    background: #fff !important; 
    overflow: hidden; 
}
#mtl-app .mtl-header { 
    background: #f8fafc; 
    padding: 25px 30px !important; 
    border-bottom: 1px solid var(--border) !important; 
}
#mtl-app button { 
    font-family: 'Inter', sans-serif !important; 
    border-radius: 8px !important; 
}

/* --- FOOTER --- */
.site-footer { 
    background: #fff; 
    border-top: 1px solid var(--border); 
    padding: 30px 0; 
    text-align: center; 
    font-size: 0.9rem; 
    color: #64748b; 
}

/* ============================================================
   MOBILE RESPONSIVE FIXES
   ============================================================ */
@media only screen and (max-width: 768px) {
    /* Header/Hero Adjustments */
    .site-header { position: relative; } 
    .page-hero { padding: 50px 20px 40px; background-size: 30px 30px; }
    .page-hero h1 { font-size: 2rem; }
    .page-hero p { font-size: 1rem; padding: 5px 10px; }

    /* --- PLUGIN FIXES --- */
    #mtl-wrapper-isolation #mtl-app { 
        padding: 0 !important; 
        box-shadow: none !important; 
        border-radius: 0 !important; 
        background: transparent !important; 
    }
    
    /* Header Plugin */
    #mtl-app .mtl-header { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 15px; 
        background: transparent; 
        padding: 10px !important; 
    }
    #mtl-app .header-controls { width: 100%; justify-content: space-between; }
    
    /* Input Boxes */
    #mtl-app .mtl-box { 
        padding: 15px !important; 
        background: #fff; 
        border-radius: 12px; 
        box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
    }
    
    /* Input Grid Container (Cuộn Ngang) */
    #mtl-app .grid-container { 
        display: grid !important; 
        gap: 5px !important; 
        padding: 10px !important; 
        margin: 0 -10px 15px -10px !important; 
        width: calc(100% + 20px) !important; 
        overflow-x: auto !important; 
        -webkit-overflow-scrolling: touch; 
        background-color: #f1f5f9 !important; 
    }
    
    /* Matrix Cells */
    #mtl-app .matrix-cell { 
        min-width: 50px !important; 
        height: 50px !important; 
        font-size: 16px !important; 
        background: #fff !important; 
    }
    
    /* Controls */
    #mtl-app .dims button { width: 40px; height: 40px; }
    #mtl-app .actions-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
    
    /* Operators Column */
    #mtl-app .mtl-ops { padding: 20px 0 !important; gap: 10px !important; }
    #mtl-app .ops-basic { 
        display: grid !important; 
        grid-template-columns: 1fr 1fr 1fr !important; 
        gap: 8px !important; 
        width: 100% !important; 
    }
    #mtl-app .btn-op { padding: 15px 5px !important; font-size: 14px !important; }
    
    /* Result Area */
    #mtl-app #mtl-result-content { padding: 20px 10px !important; }
}