/* 全局樣式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

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

/* Header */
header {
    background: white;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

header h1 i {
    margin-right: 15px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* Card 樣式 */
.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.card h2 {
    color: #667eea;
    font-size: 1.8em;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h3 {
    color: #764ba2;
    font-size: 1.4em;
    margin-bottom: 20px;
    margin-top: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 基本設定區 */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.setting-item {
    display: flex;
    flex-direction: column;
}

.setting-item label {
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.setting-item input,
.setting-item select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
    font-family: 'Noto Sans TC', sans-serif;
}

.setting-item input:focus,
.setting-item select:focus {
    outline: none;
    border-color: #667eea;
}

.setting-item small {
    color: #999;
    font-size: 0.85em;
    margin-top: 5px;
}

/* 油脂配方區 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

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

.oil-item {
    display: grid;
    grid-template-columns: 2fr 1fr 100px;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    align-items: center;
    transition: background 0.3s ease;
}

.oil-item:hover {
    background: #e9ecef;
}

.oil-select-wrapper,
.oil-percentage-wrapper {
    display: flex;
    flex-direction: column;
}

.oil-select-wrapper label,
.oil-percentage-wrapper label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

.oil-select-wrapper select,
.oil-percentage-wrapper input {
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: 'Noto Sans TC', sans-serif;
}

.oil-select-wrapper select:focus,
.oil-percentage-wrapper input:focus {
    outline: none;
    border-color: #667eea;
}

.oil-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-size: 1.2em;
}

.oil-remove:hover {
    background: #c82333;
}

.oil-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
    font-size: 1.3em;
    font-weight: 600;
    padding: 15px;
    background: #e3f2fd;
    border-radius: 8px;
}

.total-value {
    color: #667eea;
    font-size: 1.4em;
}

.total-value.valid {
    color: #28a745;
}

.total-value.invalid {
    color: #dc3545;
}

/* 按鈕樣式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Noto Sans TC', sans-serif;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* 計算結果區 */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.result-card.highlight {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.result-label {
    font-size: 0.95em;
    opacity: 0.9;
    margin-bottom: 10px;
}

.result-value {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 5px;
}

.result-note {
    font-size: 0.85em;
    opacity: 0.8;
}

/* 皂體特性分析 */
.properties {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-top: 30px;
}

.property-bars {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.property-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.property-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.property-label {
    font-weight: 600;
    color: #555;
}

.property-value {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1em;
}

.progress-bar {
    height: 25px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    font-weight: 600;
}

.property-note {
    color: #999;
    font-size: 0.85em;
}

/* 油脂用量明細表格 */
.oil-details {
    margin-top: 30px;
}

#oilDetailsTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#oilDetailsTable thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#oilDetailsTable th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

#oilDetailsTable tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.3s ease;
}

#oilDetailsTable tbody tr:hover {
    background: #f8f9fa;
}

#oilDetailsTable td {
    padding: 12px 15px;
}

/* 操作按鈕區 */
.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* 已保存配方 */
.saved-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 1.1em;
}

.saved-recipe-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
}

.saved-recipe-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.saved-recipe-item h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.saved-recipe-item p {
    color: #666;
    font-size: 0.9em;
    margin: 5px 0;
}

.saved-recipe-item .recipe-date {
    color: #999;
    font-size: 0.85em;
    margin-top: 10px;
}

.saved-recipe-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

/* Footer */
footer {
    background: white;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    margin-top: 30px;
    color: #666;
}

/* 響應式設計 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .oil-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .saved-list {
        grid-template-columns: 1fr;
    }
}

/* 動畫效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.oil-item {
    animation: fadeIn 0.3s ease;
}

/* 打印樣式 */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }

    .btn,
    .saved-recipes,
    .action-buttons {
        display: none;
    }
}
