/* ========================================
   Thisgun Saju - 사주팔자 운세 스타일
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;700;900&display=swap');

#thisgun-saju-app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Noto Serif KR', serif;
    color: #e0d5c1;
}

/* Section base */
.saju-section {
    background: #1a1a2e;
    border: 2px solid #DAA520;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.saju-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(circle at 10% 10%, rgba(218,165,32,0.05) 0%, transparent 50%),
        radial-gradient(circle at 90% 90%, rgba(139,0,0,0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* Header */
.saju-header {
    text-align: center;
    margin-bottom: 30px;
}

.saju-header h2 {
    font-size: 2.5em;
    color: #DAA520;
    margin: 0 0 5px;
    text-shadow: 0 0 20px rgba(218,165,32,0.3);
    letter-spacing: 0.3em;
}

.saju-header h3 {
    font-size: 1.4em;
    color: #e0d5c1;
    margin: 0 0 10px;
    font-weight: 400;
}

.saju-subtitle {
    color: #a09880;
    font-size: 0.95em;
    margin: 0;
}

/* Form */
.saju-form {
    max-width: 500px;
    margin: 0 auto;
}

.saju-form-group {
    margin-bottom: 20px;
}

.saju-form-group label {
    display: block;
    color: #DAA520;
    font-size: 0.95em;
    margin-bottom: 8px;
    font-weight: 700;
}

.saju-form-group input[type="text"],
.saju-form-group select {
    width: 100%;
    padding: 12px 15px;
    background: #16213e;
    border: 1px solid #DAA520;
    border-radius: 8px;
    color: #e0d5c1;
    font-size: 1em;
    font-family: 'Noto Serif KR', serif;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.saju-form-group input[type="text"]:focus,
.saju-form-group select:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 10px rgba(218,165,32,0.3);
}

.saju-date-selectors {
    display: flex;
    gap: 10px;
}

.saju-date-selectors select {
    flex: 1;
}

/* Gender */
.saju-gender-group {
    display: flex;
    gap: 20px;
}

.saju-radio-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 20px;
    background: #16213e;
    border: 1px solid #DAA520;
    border-radius: 8px;
    flex: 1;
    justify-content: center;
    transition: all 0.3s;
    color: #e0d5c1 !important;
    font-weight: 400 !important;
    margin-bottom: 0 !important;
}

.saju-radio-label:has(input:checked) {
    background: rgba(139,0,0,0.4);
    border-color: #FFD700;
    box-shadow: 0 0 10px rgba(218,165,32,0.3);
}

.saju-radio-label input[type="radio"] {
    accent-color: #DAA520;
}

/* Submit Button */
.saju-submit-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #8B0000, #5c0000);
    color: #FFD700;
    border: 2px solid #DAA520;
    border-radius: 8px;
    font-size: 1.2em;
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.1em;
    margin-top: 10px;
}

.saju-submit-btn:hover {
    background: linear-gradient(135deg, #a00000, #700000);
    box-shadow: 0 0 20px rgba(139,0,0,0.5);
    transform: translateY(-2px);
}

.saju-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Loading */
.saju-loading {
    text-align: center;
    padding: 40px;
}

.saju-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(218,165,32,0.2);
    border-top: 4px solid #DAA520;
    border-radius: 50%;
    animation: sajuSpin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes sajuSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.saju-loading p {
    color: #DAA520;
    font-size: 1.1em;
}

/* ========================================
   Result Styles
   ======================================== */

/* Result Header */
.saju-result-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(218,165,32,0.3);
}

.saju-result-header h2 {
    font-size: 2em;
    color: #DAA520;
    margin: 0 0 5px;
}

.saju-result-header .saju-user-info {
    color: #a09880;
    font-size: 0.95em;
}

/* Four Pillars Table */
.saju-pillars-container {
    margin: 25px 0;
}

.saju-pillars-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 8px;
    table-layout: fixed;
}

.saju-pillars-table th {
    background: linear-gradient(135deg, #8B0000, #5c0000);
    color: #FFD700;
    padding: 10px;
    border-radius: 8px 8px 0 0;
    font-size: 1.1em;
    letter-spacing: 0.1em;
    border: 1px solid #DAA520;
}

.saju-pillar-cell {
    background: #16213e;
    border: 1px solid #DAA520;
    padding: 15px 10px;
    text-align: center;
    vertical-align: middle;
}

.saju-stem-cell {
    border-radius: 0;
    font-size: 1.8em;
    font-weight: 700;
}

.saju-branch-cell {
    border-radius: 0 0 8px 8px;
    font-size: 1.8em;
    font-weight: 700;
}

.saju-char-hanja {
    display: block;
    font-size: 1em;
}

.saju-char-hangul {
    display: block;
    font-size: 0.5em;
    color: #a09880;
    margin-top: 4px;
}

.saju-element-label {
    display: inline-block;
    font-size: 0.35em;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    font-weight: 400;
}

/* Element colors */
.elem-wood { color: #4CAF50; }
.elem-fire { color: #f44336; }
.elem-earth { color: #FFC107; }
.elem-metal { color: #e0e0e0; }
.elem-water { color: #2196F3; }

.elem-bg-wood { background: rgba(76,175,80,0.2); color: #4CAF50; }
.elem-bg-fire { background: rgba(244,67,54,0.2); color: #f44336; }
.elem-bg-earth { background: rgba(255,193,7,0.2); color: #FFC107; }
.elem-bg-metal { background: rgba(224,224,224,0.2); color: #e0e0e0; }
.elem-bg-water { background: rgba(33,150,243,0.2); color: #2196F3; }

/* Result Section Cards */
.saju-result-card {
    background: rgba(22,33,62,0.6);
    border: 1px solid rgba(218,165,32,0.3);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
}

.saju-result-card h3 {
    color: #DAA520;
    font-size: 1.3em;
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(218,165,32,0.2);
}

.saju-result-card p {
    line-height: 1.8;
    margin: 10px 0;
    color: #d4c9b5;
}

/* Five Elements Chart */
.saju-elements-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 180px;
    padding: 20px 0;
    margin: 15px 0;
    border-bottom: 2px solid rgba(218,165,32,0.3);
}

.saju-element-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.saju-element-bar {
    width: 40px;
    border-radius: 6px 6px 0 0;
    min-height: 5px;
    transition: height 1s ease;
    position: relative;
}

.saju-element-bar.wood { background: linear-gradient(to top, #2E7D32, #4CAF50); }
.saju-element-bar.fire { background: linear-gradient(to top, #C62828, #f44336); }
.saju-element-bar.earth { background: linear-gradient(to top, #F57F17, #FFC107); }
.saju-element-bar.metal { background: linear-gradient(to top, #9E9E9E, #E0E0E0); }
.saju-element-bar.water { background: linear-gradient(to top, #1565C0, #2196F3); }

.saju-element-count {
    font-size: 0.9em;
    color: #e0d5c1;
    margin-bottom: 5px;
    font-weight: 700;
}

.saju-element-name {
    margin-top: 8px;
    font-size: 0.95em;
    color: #a09880;
}

/* Element circles row */
.saju-elements-circles {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.saju-element-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85em;
    border: 2px solid rgba(255,255,255,0.2);
}

.saju-element-circle.wood { background: radial-gradient(circle, #4CAF50, #2E7D32); color: #fff; }
.saju-element-circle.fire { background: radial-gradient(circle, #f44336, #B71C1C); color: #fff; }
.saju-element-circle.earth { background: radial-gradient(circle, #FFC107, #F57F17); color: #333; }
.saju-element-circle.metal { background: radial-gradient(circle, #E0E0E0, #9E9E9E); color: #333; }
.saju-element-circle.water { background: radial-gradient(circle, #2196F3, #0D47A1); color: #fff; }

.saju-element-circle span {
    display: block;
    font-size: 0.8em;
    opacity: 0.8;
}

/* Action buttons */
.saju-result-actions {
    text-align: center;
    margin-top: 20px;
}

.saju-action-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #8B0000, #5c0000);
    color: #FFD700;
    border: 2px solid #DAA520;
    border-radius: 8px;
    font-size: 1em;
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin: 5px;
}

.saju-action-btn:hover {
    background: linear-gradient(135deg, #a00000, #700000);
    box-shadow: 0 0 15px rgba(139,0,0,0.4);
}

/* ========================================
   History
   ======================================== */

.saju-history-title {
    color: #DAA520;
    font-size: 1.3em;
    margin: 0 0 20px;
    text-align: center;
}

.saju-history-empty {
    text-align: center;
    color: #666;
    padding: 20px;
}

.saju-history-item {
    background: rgba(22,33,62,0.5);
    border: 1px solid rgba(218,165,32,0.2);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.saju-history-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.3s;
}

.saju-history-summary:hover {
    background: rgba(218,165,32,0.05);
}

.saju-history-info {
    flex: 1;
}

.saju-history-info strong {
    color: #DAA520;
    margin-right: 10px;
}

.saju-history-info span {
    color: #a09880;
    font-size: 0.9em;
}

.saju-history-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.saju-history-toggle {
    background: none;
    border: 1px solid rgba(218,165,32,0.3);
    color: #DAA520;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: 'Noto Serif KR', serif;
}

.saju-history-delete {
    background: none;
    border: 1px solid rgba(139,0,0,0.5);
    color: #8B0000;
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: 'Noto Serif KR', serif;
}

.saju-history-toggle:hover {
    background: rgba(218,165,32,0.1);
}

.saju-history-delete:hover {
    background: rgba(139,0,0,0.2);
}

.saju-history-detail {
    display: none;
    padding: 15px;
    border-top: 1px solid rgba(218,165,32,0.1);
    max-height: 400px;
    overflow-y: auto;
}

.saju-history-detail.open {
    display: block;
}

/* Scrollbar */
.saju-history-detail::-webkit-scrollbar {
    width: 6px;
}
.saju-history-detail::-webkit-scrollbar-track {
    background: #16213e;
}
.saju-history-detail::-webkit-scrollbar-thumb {
    background: #DAA520;
    border-radius: 3px;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 600px) {
    #thisgun-saju-app {
        padding: 10px;
    }

    .saju-section {
        padding: 20px 15px;
    }

    .saju-header h2 {
        font-size: 1.8em;
    }

    .saju-header h3 {
        font-size: 1.1em;
    }

    .saju-date-selectors {
        flex-direction: column;
        gap: 8px;
    }

    .saju-gender-group {
        flex-direction: column;
        gap: 10px;
    }

    .saju-pillars-table th {
        font-size: 0.85em;
        padding: 8px 4px;
    }

    .saju-stem-cell,
    .saju-branch-cell {
        font-size: 1.3em;
        padding: 10px 5px;
    }

    .saju-elements-chart {
        height: 140px;
    }

    .saju-element-bar {
        width: 30px;
    }

    .saju-element-circle {
        width: 50px;
        height: 50px;
        font-size: 0.75em;
    }

    .saju-history-summary {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .saju-result-card {
        padding: 15px;
    }

    .saju-result-card h3 {
        font-size: 1.1em;
    }
}

/* Animation */
@keyframes sajuFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.saju-result-card {
    animation: sajuFadeIn 0.5s ease forwards;
}

.saju-result-card:nth-child(2) { animation-delay: 0.1s; }
.saju-result-card:nth-child(3) { animation-delay: 0.2s; }
.saju-result-card:nth-child(4) { animation-delay: 0.3s; }
.saju-result-card:nth-child(5) { animation-delay: 0.4s; }
.saju-result-card:nth-child(6) { animation-delay: 0.5s; }
.saju-result-card:nth-child(7) { animation-delay: 0.6s; }
.saju-result-card:nth-child(8) { animation-delay: 0.7s; }
.saju-result-card:nth-child(9) { animation-delay: 0.8s; }

/* Decorative corner patterns */
.saju-section::after {
    content: '☰';
    position: absolute;
    top: 8px;
    right: 12px;
    color: rgba(218,165,32,0.15);
    font-size: 1.5em;
}
