/*
 * Prime Factor Calculator Styles
 * Calculator: 質數/因數計算器 | Prime Number & Factor Calculator
 * Created: 2025-01-15
 */

/* ===== Main Container ===== */
.main-container {
    padding: 2rem 0;
}


/* ===== Form Input Fields ===== */
.form-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-label i {
    color: #667eea;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #e0e7ff;
    border-radius: 8px;
    background: white;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input:hover {
    border-color: #a5b4fc;
}

/* Input validation states */
.form-input.is-invalid {
    border-color: #ef4444;
}

.form-input.is-valid {
    border-color: #48bb78;
}

.input-help-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

.input-error-text {
    font-size: 0.85rem;
    color: #ef4444;
    margin-top: 0.25rem;
    display: none;
}

.form-input.is-invalid + .input-error-text {
    display: block;
}

/* ===== Action Buttons Grid (MANDATORY) ===== */
.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Action Buttons */
.btn-custom,
.btn-custom-outline {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

.btn-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-custom-outline {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-custom-outline:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8edff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.btn-custom:active,
.btn-custom-outline:active {
    transform: translateY(0);
}

/* Sponsor Button */
.btn-sponsor {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

.btn-sponsor:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-sponsor:active {
    transform: translateY(0);
}

/* ===== Results Display ===== */
.result-section {
    margin-top: 1rem;
}

.result-item {
    padding: 1rem;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8edff 100%);
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
}

.result-item-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.result-item-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #667eea;
    word-break: break-word;
}

.result-item-value.is-prime {
    color: #48bb78;
}

.result-item-value.is-composite {
    color: #764ba2;
}

/* Prime Check Badge */
.prime-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
}

.prime-badge.is-prime {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.prime-badge.is-composite {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
}

.prime-badge.is-special {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

/* ===== Factors Display ===== */
.factors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.factor-item {
    padding: 0.5rem;
    background: white;
    border: 2px solid #e0e7ff;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
    transition: all 0.2s ease;
}

.factor-item:hover {
    border-color: #667eea;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.factor-item.is-prime {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #48bb78;
    color: #48bb78;
}

/* ===== Prime Factorization Display ===== */
.prime-factorization {
    font-size: 1.5rem;
    font-weight: 600;
    color: #764ba2;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    text-align: center;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

/* Superscript for exponents */
.prime-factorization sup {
    font-size: 0.8em;
    color: #667eea;
}

/* ===== Algorithm Steps (Educational Mode) ===== */
.algorithm-steps {
    margin-top: 1rem;
    display: none;
}

.algorithm-steps.show {
    display: block;
}

.algorithm-step {
    padding: 0.75rem 1rem;
    background: white;
    border-left: 3px solid #667eea;
    margin-bottom: 0.5rem;
    border-radius: 0 8px 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #333;
}

.algorithm-step-number {
    display: inline-block;
    width: 30px;
    height: 30px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    font-weight: 600;
    margin-right: 0.5rem;
}

.algorithm-toggle {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.algorithm-toggle:hover {
    background: #f0f4ff;
}

.algorithm-toggle i {
    transition: transform 0.3s ease;
}

.algorithm-toggle.active i {
    transform: rotate(180deg);
}

/* ===== Chart Container ===== */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: 1rem;
}

/* ===== Tooltips ===== */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: help;
    margin-left: 0.25rem;
}

/* ===== Performance Warning ===== */
.performance-warning {
    display: none;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    margin-top: 1rem;
}

.performance-warning i {
    color: #f59e0b;
    margin-right: 0.5rem;
}

.performance-warning.show {
    display: block;
}


/* ===== Phase 2: Advanced Features Styles ===== */
.advanced-features {
    margin-top: 3rem;
}

.advanced-description {
    font-size: 1rem;
    color: #666;
    margin-top: 0.5rem;
}

/* Prime List Result */
.prime-list-result {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
}

.result-summary {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #333;
}

.prime-list {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.8;
    word-wrap: break-word;
}

.no-result {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* Twin Primes Result */
.twin-primes-result {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
}

.twin-pairs {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.8;
    word-wrap: break-word;
}

/* Mersenne Prime Result */
.mersenne-result {
    margin-top: 1rem;
}

.mersenne-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.mersenne-badge.is-prime {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.mersenne-badge.is-composite {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.mersenne-badge.is-special {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

.mersenne-details {
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
}

.mersenne-details p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.mersenne-details p:last-child {
    margin-bottom: 0;
}

/* Euler's Totient Result */
.euler-result {
    margin-top: 1rem;
}

.euler-summary {
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.euler-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.euler-formula {
    font-size: 0.95rem;
    color: #666;
    font-family: 'Courier New', monospace;
}

.coprime-list {
    padding: 1rem;
    background: rgba(72, 187, 120, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.8;
}

/* ===== Responsive Design ===== */

/* Tablet */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 2rem;
    }

    .page-header .subtitle {
        font-size: 1rem;
    }

    .result-item-value {
        font-size: 1.5rem;
    }

    .prime-factorization {
        font-size: 1.2rem;
    }

    .factors-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }

    .chart-container {
        height: 250px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .page-header h1 {
        font-size: 1.6rem;
    }

    .page-header .subtitle {
        font-size: 0.9rem;
    }

    .glass-card {
        padding: 1rem;
    }

    .glass-card h3 {
        font-size: 1.1rem;
    }

    .action-buttons-grid {
        grid-template-columns: 1fr;
    }

    .result-item-value {
        font-size: 1.3rem;
    }

    .prime-factorization {
        font-size: 1rem;
    }

    .factors-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 0.4rem;
    }

    .factor-item {
        padding: 0.4rem;
        font-size: 0.9rem;
    }

    .chart-container {
        height: 200px;
    }

    .algorithm-step {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .seo-section h2 {
        font-size: 1.5rem;
    }

    .seo-section h3 {
        font-size: 1.2rem;
    }
}

/* ===== Loading State ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Keyboard Shortcut Hints ===== */
.keyboard-hint {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.5rem;
    text-align: center;
}

.keyboard-hint kbd {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
}

/* ===== Print Styles (for PDF Export) ===== */
@media print {
    .action-buttons-grid,
    .algorithm-toggle,
    .btn-custom,
    .btn-custom-outline,
    .btn-sponsor {
        display: none !important;
    }

    .glass-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .page-header h1 {
        color: #667eea !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
