/* 數學公式計算器樣式 - 兒童友好版 */

/* 重置 Foundation 樣式 */
* {
    box-sizing: border-box;
}

body {
    font-family: "標楷體", "KaiTi", serif !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

/* 統一中文字體 */
h1, h2, h3, h4, h5, h6, 
label, 
.button, 
.category-menu, 
.formula-display,
.result-display,
.operator-selection {
    font-family: "標楷體", "KaiTi", serif !important;
}

/* 主容器 */
.grid-container {
    max-width: 1200px;
    margin: 0 auto;
}

.number-input {
    font-family: "Times New Roman", serif;
}

.formula-display {
    background: linear-gradient(145deg, #ffffff, #f8f9fa) !important;
    padding: 30px !important;
    border-radius: 20px !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important;
    margin-bottom: 20px !important;
    border: 3px solid #2196F3 !important;
    width: 100% !important;
    max-width: none !important;
}

.input-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: normal;
    color: #000000;
    font-size: 1.2em;
    margin-bottom: 5px;
}

.input-group input {
    font-family: "Times New Roman", serif;
    font-size: 1.1em;
    padding: 15px 20px;
    border: 3px solid #2196F3;
    border-radius: 15px;
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    min-width: 200px;
}

.input-group input:focus {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 15px rgba(25, 118, 210, 0.3);
    transform: translateY(-2px);
}

.input-invalid {
    background: linear-gradient(145deg, #FFEBEE, #FFCDD2) !important;
    border-color: #F44336 !important;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.3) !important;
}

.calculated-field {
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB) !important;
    border-color: #2196F3 !important;
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.4) !important;
    transform: scale(1.02) !important;
}

.category-menu {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    height: fit-content;
    min-width: 10em;
    border: 3px solid #2196F3;
}

.category-menu h3 {
    color: #1976D2;
    margin-bottom: 25px;
    font-size: 1.4em;
    text-align: center;
    font-weight: normal;
}

.category-menu .button {
    width: 100%;
    margin-bottom: 15px;
    text-align: center;
    min-width: 8em;
    white-space: nowrap;
    font-size: 1.1em;
    padding: 15px 20px;
    border-radius: 15px;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: normal;
}

.category-menu .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.elementary-btn {
    background: linear-gradient(45deg, #4CAF50, #388E3C);
    color: white;
    border-color: #2E7D32;
}

.middle-btn {
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
    border-color: #1565C0;
}

.high-btn {
    background: linear-gradient(45deg, #9C27B0, #7B1FA2);
    color: white;
    border-color: #6A1B9A;
}

.subcategory-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
}

.subcategory-button {
    font-size: 1em;
    padding: 12px 16px;
    min-width: 8em;
    white-space: nowrap;
    text-align: center;
    background: linear-gradient(45deg, #2196F3, #21CBF3);
    color: white;
    border-radius: 12px;
    border: 2px solid #1976D2;
    transition: all 0.3s ease;
    font-weight: normal;
}

.subcategory-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    background: linear-gradient(45deg, #1976D2, #1E88E5);
}

.result-display {
    background-color: #f0f8ff;
    padding: 15px;
    border-radius: 5px;
    margin-top: 15px;
    border-left: 4px solid #2196f3;
}

.reset-button {
    background-color: #ff6b6b;
    color: white;
}

.reset-button:hover {
    background-color: #ff5252;
}

.operator-selection {
    margin-bottom: 25px;
    padding: 25px;
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    border-radius: 20px;
    border: 3px solid #2196F3;
    box-shadow: 0 5px 20px rgba(33, 150, 243, 0.2);
}

.operator-selection label {
    display: block;
    margin-bottom: 15px;
    font-weight: normal;
    color: #1976D2;
    font-size: 1.3em;
    text-align: center;
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.operator-btn {
    min-width: 60px;
    height: 60px;
    font-size: 3em;
    font-weight: normal;
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    color: #1976D2;
    border: 3px solid #2196F3;
    border-radius: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.operator-btn:hover {
    background: linear-gradient(145deg, #BBDEFB, #90CAF9);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.operator-btn.active {
    background: linear-gradient(145deg, #2196F3, #1976D2);
    color: white;
    border-color: #1565C0;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(33, 150, 243, 0.4);
}

/* 形狀選擇樣式 */
.shape-selection {
    text-align: center;
    padding: 20px;
}

.shape-selection h4 {
    color: #1976D2;
    margin-bottom: 30px;
    font-size: 1.4em;
    font-weight: normal;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.shape-option {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border: 3px solid #2196F3;
    border-radius: 20px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
}

.shape-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(33, 150, 243, 0.3);
    border-color: #1976D2;
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
}

.shape-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 15px;
    border-radius: 10px;
}

.shape-option h5 {
    color: #1976D2;
    margin: 10px 0;
    font-size: 1.2em;
    font-weight: normal;
}


.shape-option p {
    color: #666;
    font-size: 0.9em;
    margin: 0;
    font-style: italic;
}

/* 公式與圖片並排顯示樣式 */
.formula-with-image {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(145deg, #FFF9C4, #FFF59D);
    border-radius: 15px;
    border: 3px solid #F57F17;
}

.formula-text {
    flex: 1;
}

.formula-text h4 {
    color: #000000;
    margin: 0 0 10px 0;
    font-size: 1.3em;
    font-weight: normal;
}

.formula-content {
    color: #000000;
    font-size: 1.1em;
    line-height: 1.4;
    font-weight: normal;
}

.formula-image {
    flex: 0 0 auto;
    background: white;
    padding: 8px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.shape-image-large {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 15px;
}

/* 回上頁按鈕樣式 */
.back-button-container {
    margin-bottom: 20px;
    text-align: left;
}

.back-button {
    background: linear-gradient(45deg, #FF6B6B, #FF5252);
    color: white;
    border: 2px solid #E53E3E;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 1em;
    transition: all 0.3s ease;
    cursor: pointer;
}

.back-button:hover {
    background: linear-gradient(45deg, #FF5252, #E53E3E);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

/* 錯誤消息樣式 */
.error-message {
    background: linear-gradient(145deg, #FFEBEE, #FFCDD2);
    color: #D32F2F;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid #F44336;
    font-weight: bold;
    text-align: center;
    margin: 0;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.2);
    font-size: 0.9em;
}

/* 響應式設計 - 小螢幕時垂直排列 */
@media (max-width: 768px) {
    .formula-with-image {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .shape-image-large {
        width: 100px;
        height: 100px;
    }
}

/* 三角函數樣式 */
.trig-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    padding: 20px;
}

.trig-button {
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    border: 2px solid #2196F3;
    color: #1976D2;
    font-weight: bold;
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 1.1em;
}

.trig-button:hover {
    background: linear-gradient(145deg, #BBDEFB, #90CAF9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

.trig-content {
    padding: 20px;
    background: linear-gradient(145deg, #FFF9C4, #FFF59D);
    border: 3px solid #F57F17;
    border-radius: 15px;
    margin: 20px 0;
}

.trig-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.trig-table th,
.trig-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid #ddd;
}

.trig-table th {
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    color: #000000;
    font-weight: normal;
    font-family: "標楷體", "KaiTi", serif;
}

.trig-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.formula-list p {
    font-size: 1.2em;
    margin: 15px 0;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #2196F3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.triangle-diagram {
    background: #E8F5E8;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #4CAF50;
    margin: 15px 0;
}

.triangle-diagram ul {
    margin: 10px 0;
    padding-left: 20px;
}

.triangle-diagram li {
    margin: 5px 0;
    color: #2E7D32;
}

/* 數學分數樣式 */
.math-fraction {
    display: inline-block;
    position: relative;
    font-size: 1.1em;
    font-weight: normal;
    color: #000000;
    background: transparent;
    padding: 6px 10px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    vertical-align: middle;
    min-width: 40px;
    text-align: center;
}

/* 真正的數學分數樣式 */
.math-fraction::before {
    content: attr(data-numerator);
    display: block;
    text-align: center;
    line-height: 1.2;
    font-size: 1em;
    font-weight: normal;
    color: #000000;
}

.math-fraction::after {
    content: attr(data-denominator);
    display: block;
    text-align: center;
    line-height: 1.2;
    font-size: 1em;
    font-weight: normal;
    color: #000000;
    border-top: 2px solid #000000;
    padding-top: 3px;
    margin-top: 3px;
}

/* 基本定義版面樣式 */
.definition-panels {
    display: flex !important;
    gap: 20px !important;
    margin-bottom: 30px !important;
    align-items: stretch !important;
}

.definition-panel {
    flex: 1 !important;
    background: white !important;
    border: 3px solid #2196F3 !important;
    border-radius: 15px !important;
    padding: 25px !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1) !important;
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: none !important;
}

.left-panel {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
}

.right-panel {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
}

.panel-title {
    font-size: 1.4em;
    color: #000000;
    font-weight: normal;
    margin: 0 0 20px 0;
    text-align: center;
    font-family: "標楷體", "KaiTi", serif;
}

/* 左側面板 - 三角函數定義 */
.trig-definitions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.trig-definition-item {
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #2196F3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.trig-formula {
    font-size: 1.4em;
    font-weight: normal;
    color: #000000;
    margin: 0;
    text-align: center;
    font-family: "Times New Roman", serif;
    line-height: 1.6;
}

.trig-formula .math-fraction {
    font-family: "Times New Roman", serif;
    color: #000000;
    margin: 0 8px;
    vertical-align: middle;
}

.math-fraction-parentheses {
    font-family: "標楷體", "KaiTi", serif;
    color: #000000;
    margin: 0 8px;
    vertical-align: middle;
}

.math-fraction-parentheses .math-fraction {
    font-family: "標楷體", "KaiTi", serif;
    color: #000000;
    margin: 0;
}

/* 右側面板 - 邊的說明 */
.side-explanations {
    margin-bottom: 20px;
    flex: 1;
}

.context-title {
    font-size: 1.2em;
    color: #000000;
    font-weight: normal;
    margin: 0 0 15px 0;
    text-align: left;
    font-family: "標楷體", "KaiTi", serif;
}

.side-definition {
    background: linear-gradient(145deg, #FFF9C4, #FFF59D);
    padding: 12px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #F57F17;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.variable-definition {
    font-size: 1.1em;
    color: #333;
    margin: 0;
    font-weight: normal;
}

.triangle-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 15px;
    border: 2px dashed #ccc;
    min-height: 150px;
}

.triangle-image {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.complete-definitions {
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    padding: 25px;
    border-radius: 15px;
    border: 3px solid #2196F3;
    margin: 20px 0;
}

.complete-definitions h4 {
    color: #1976D2;
    margin: 0 0 20px 0;
    font-size: 1.4em;
    font-weight: bold;
}

/* 基本關係恆等式版面樣式 */
.identities-panels {
    display: flex !important;
    gap: 20px !important;
    margin-bottom: 20px !important;
    align-items: stretch !important;
}

.identity-panel {
    flex: 1 !important;
    background: white !important;
    border: 3px solid #2196F3 !important;
    border-radius: 15px !important;
    padding: 25px !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1) !important;
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: none !important;
}

.left-panel {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
}

.right-panel {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
}

.quotient-relations-panel {
    background: white;
    border: 3px solid #2196F3;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
    margin-top: 20px;
}

.quotient-formulas {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.quotient-formulas .clickable-formula {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.quotient-formula-display {
    font-size: 1.2em;
    margin: 15px 0;
    padding: 10px;
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    border-radius: 8px;
    border-left: 4px solid #2196F3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-family: "Times New Roman", serif;
    color: #000000;
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.clickable-formula {
    font-size: 1.2em;
    margin: 15px 0;
    padding: 10px;
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    border-radius: 8px;
    border-left: 4px solid #2196F3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: "Times New Roman", serif;
    color: #000000;
}

.clickable-formula:hover {
    background: linear-gradient(145deg, #BBDEFB, #90CAF9);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.image-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    padding: 10px;
    align-self: center;
}

.identity-image {
    max-width: 120px;
    max-height: 120px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    transform: scale(1.5);
}

/* 響應式設計 - 根據螢幕大小調整 */
@media (max-width: 1200px) {
    .triangle-image {
        max-width: 120px;
        max-height: 120px;
    }
    
    .identity-image {
        max-width: 60px;
        max-height: 60px;
    }
}

@media (max-width: 768px) {
    .definition-panels,
    .identities-panels {
        flex-direction: column;
        gap: 15px;
    }
    
    .trig-formula {
        font-size: 1.2em;
    }
    
    .triangle-image {
        max-width: 100px;
        max-height: 100px;
    }
    
    .triangle-placeholder {
        min-height: 120px;
        padding: 15px;
    }
    
    .quotient-formulas {
        flex-direction: column;
        gap: 15px;
    }
    
    .quotient-formulas .clickable-formula {
        min-width: auto;
        max-width: none;
    }
    
    .identity-image {
        max-width: 80px;
        max-height: 80px;
        transform: scale(1.2);
    }
}

@media (max-width: 480px) {
    .definition-panel,
    .identity-panel {
        padding: 15px;
    }
    
    .trig-formula {
        font-size: 1.1em;
    }
    
    .triangle-image {
        max-width: 80px;
        max-height: 80px;
    }
    
    .triangle-placeholder {
        min-height: 100px;
        padding: 10px;
    }
    
    .quotient-formulas {
        flex-direction: column;
        gap: 10px;
    }
    
    .identity-image {
        max-width: 60px;
        max-height: 60px;
        transform: scale(1.0);
    }
}

/* 乘法公式樣式 */
.multiplication-content {
    padding: 20px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 15px;
    border: 3px solid #2196F3;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.multiplication-content h3 {
    color: #000000;
    font-size: 1.6em;
    margin: 0 0 25px 0;
    text-align: center;
    font-weight: bold;
    font-family: "標楷體", "KaiTi", serif;
}

.multiplication-content .formula-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.multiplication-content .formula-item {
    background: linear-gradient(145deg, #E3F2FD, #BBDEFB);
    padding: 20px;
    border-radius: 12px;
    border-left: 5px solid #2196F3;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.multiplication-content .formula-item h4 {
    color: #000000;
    font-size: 1.3em;
    margin: 0 0 15px 0;
    font-weight: bold;
    font-family: "標楷體", "KaiTi", serif;
}

.multiplication-content .formula-item p {
    font-size: 1.2em;
    margin: 8px 0;
    color: #000000;
    font-family: "Times New Roman", serif;
    line-height: 1.6;
}

.multiplication-content .formula-item strong {
    color: #000000;
    font-weight: bold;
}
