/* Delete button styles */
.delete-button {
    padding: 5px 10px;
    background-color: #ff6666; /* Lighter red */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 0.9em;
}

.delete-button:hover {
    background-color: #ff4444; /* Standard danger red */
}

/* Save button styles */
.save-button {
    padding: 10px 20px;
    background-color: white;
    color: #4CAF50;
    border: 2px solid #4CAF50;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
    font-size: 1em;
}

.save-button:hover {
    background-color: #4CAF50;
    color: white;
}

.save-button:disabled {
    background-color: #cccccc;
    border-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

/* Profile page styles */
.profile-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.profile-content {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.profile-content h2 {
    margin-bottom: 20px;
    color: #333;
}

#user-info {
    font-size: 1.1em;
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 4px;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 20px auto 0 auto;
    width: 200px;
}

/* Base Button Style */
.button-style,
button,
.profile-nav {
    display: inline-block;
    padding: 8px 15px;
    font-size: 1em;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    color: white;
    background-color: #5cb85c; /* Green */
    border: 1px solid #4cae4c;
    border-radius: 4px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    margin: 5px 0;
    vertical-align: middle;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
}

.button-style:hover,
button:hover,
.profile-nav:hover {
    background-color: #4cae4c;
    color: white;
}

/* New Destructive Outline Style */
.button-destructive-outline {
    background-color: white !important; /* Override base style */
    color: #d9534f !important; /* Red text */
    border: 1px solid #d9534f !important; /* Red border */
    /* Inherit padding, border-radius, cursor, font-size, transition, etc., from .button-style */
}

.button-destructive-outline:hover {
    background-color: #fdf3f3 !important; /* Very light red background on hover */
    color: #c9302c !important; /* Darker red text on hover */
    border-color: #c9302c !important; /* Darker red border on hover */
}

/* New Primary (Green) Outline Style */
.button-primary-outline {
    background-color: white !important; /* Override base style */
    color: #5cb85c !important; /* Green text */
    border: 1px solid #4cae4c !important; /* Green border */
    /* Inherit padding, border-radius, cursor, font-size, transition, etc., from .button-style */
}

.button-primary-outline:hover {
    background-color: #f1f8f1 !important; /* Very light green background on hover */
    color: #4cae4c !important; /* Darker green text on hover */
    border-color: #4cae4c !important; /* Darker green border on hover */
}

/* New Info (Blue) Outline Style */
.button-info-outline {
    background-color: white !important; /* Override base style */
    color: #337ab7 !important; /* Blue text */
    border: 1px solid #2e6da4 !important; /* Blue border */
    /* Inherit padding, border-radius, cursor, font-size, transition, etc., from .button-style */
}

.button-info-outline:hover {
    background-color: #e7f1f9 !important; /* Very light blue background on hover */
    color: #286090 !important; /* Darker blue text on hover */
    border-color: #204d74 !important; /* Darker blue border on hover */
}

/* Calculation history styles */
.calculation-history {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.history-table-container {
    margin-top: 15px;
    overflow-x: auto;
}

#history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
}

#history-table th,
#history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

#history-table th {
    background-color: #f8f8f8;
    font-weight: 600;
}

#history-table tbody tr:hover {
    background-color: #f5f5f5;
}

.loading-message {
    text-align: center;
    color: #666;
    padding: 20px;
}

/* Auth styles */
.auth-container {
    margin-bottom: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
}

.user-info span {
    font-weight: 500;
    color: #333;
}

#logout-button {
    padding: 8px 16px;
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#logout-button:hover {
    background-color: #cc0000;
}

/* 現有的樣式 */
body {
    font-family: 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 430px; /* iPhone 15 Pro Max 的螢幕寬度 */
    margin: 0 auto; /* 讓內容置中 */
    padding: 20px;
    background-color: white; /* 添加背景色以區分留白 */
    width: 100%; /* 確保內容不超出螢幕 */
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.intro {
    color: #666;
    margin-bottom: 2rem;
}

/* Auth Section Styles */
.auth-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 0 auto;
}

.auth-container h2 {
    margin-top: 0;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

button {
    width: 100%;
    padding: 0.75rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

#auth-error, #signup-error {
    color: #e74c3c;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

#signup-message {
    color: #27ae60;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.auth-container p {
    text-align: center;
    margin-top: 1rem;
}

.auth-container a {
    color: #3498db;
    text-decoration: none;
}

.auth-container a:hover {
    text-decoration: underline;
}

/* Calculator Section Styles */
.calculator {
    background: white;
    padding: clamp(1rem, 5vw, 2rem); /* Responsive padding */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

#grid-container {
    display: grid;
    grid-template-columns: repeat(3, 90px); /* Fixed width columns (Desktop) */
    gap: 10px;
    margin: 2rem auto; /* Center the fixed-width container */
    width: 290px; /* Explicit fixed width (3*90 + 2*10) */
    box-sizing: border-box; /* Keep for potential future padding/border */
}

.grid-cell {
    border: 2px solid #ccc;
    font-size: 18px;
    font-weight: bold;
    position: relative; /* Keep for absolute children */
    background-color: #fff;
    border-radius: 4px;
    height: 90px; /* Explicitly set height (Desktop) */
    width: 90px; /* Explicitly set width (Desktop) */
}

/* Position content inside the cell */
.grid-cell > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex; /* Use flex on the positioned element */
    align-items: center;
    justify-content: center;
}

.grid-cell .number {
    z-index: 1;
}

.grid-cell .shape-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* SVG shapes with specific colors */
.grid-cell .shape-svg circle {
    fill: none;
    stroke: rgb(52, 152, 219);  /* 圓形：藍色 */
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.grid-cell .shape-svg polygon {
    fill: none;
    stroke: rgb(46, 204, 113);  /* 三角形：綠色 */
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.grid-cell .shape-svg rect {
    fill: none;
    stroke: rgb(218, 63, 32);   /* 正方形：紅色 */
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.controls {
    margin-top: 2rem;
    display: flex;
    flex-direction: column; /* Stack controls vertically */
    align-items: center; /* Center items horizontally */
}

.control-group {
    margin-bottom: 1rem;
    width: 100%; /* Make control groups take full width */
    max-width: 400px; /* Limit max width */
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
}

.control-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box; /* Include padding and border in width */
}

#error-message {
    color: red;
    margin-top: 1rem;
    min-height: 1em; /* Reserve space for the error message */
}

/* Results Section Styles */
.results {
    background: #e9f5ff;
    padding: clamp(1rem, 5vw, 2rem);
    border-radius: 8px;
    margin-top: 2rem;
    margin-bottom: 2rem;
    border: 1px solid #bde0ff;
}

.results h2 {
    margin-top: 0;
    color: #0056b3;
    margin-bottom: 1.5rem;
}

#results-display p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
    color: #333;
}

#results-display span {
    font-weight: bold;
    color: #0056b3;
    margin-left: 0.5rem;
}

#results-display small {
    font-size: 0.85rem;
    color: #666;
    margin-left: 0.5rem;
}

#trait-advice {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed #bde0ff;
}

.trait-text, .advice-text {
    margin: 0.8rem 0;
    line-height: 1.7;
    color: #222;
    font-size: 1rem;
}

/* Explanation Section Styles */
.explanation {
    background: #fffbe6;
    padding: clamp(1rem, 5vw, 2rem);
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #fff1b3;
}

.explanation h2 {
    margin-top: 0;
    color: #d48806;
    margin-bottom: 1.5rem;
}

.explanation p, .explanation ul {
    color: #555;
    line-height: 1.7;
    font-size: 1rem;
}

.explanation ul {
    padding-left: 20px;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.explanation li {
    margin-bottom: 0.5rem;
}

/* Ad Container Styles */
.ad-container {
    margin: 2rem auto; /* Center the ad container */
    max-width: 728px; /* Typical banner ad width */
    text-align: center; /* Center the ad unit */
    min-height: 90px; /* Minimum height for the ad slot */
    background-color: #f0f0f0; /* Placeholder background */
    border: 1px dashed #ccc; /* Placeholder border */
    display: flex;
    justify-content: center;
    align-items: center;
}

footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    color: #777;
    font-size: 0.9rem;
}

/* Responsive styling for mobile devices */
@media screen and (max-width: 600px) {
    .container {
        width: 100%;
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .intro {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
        padding: 0 10px;
    }

    .auth-container {
        padding: 1rem;
        width: 90%;
        margin: 0 auto;
    }

    .calculator, .results, .explanation {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 6px;
    }

    #grid-container {
        grid-template-columns: repeat(3, 70px); /* Fixed width columns (Mobile) */
        width: 220px; /* Explicit fixed width (3*70 + 2*5) */
        gap: 5px;
        margin: 1rem auto;
        padding: 0; /* Remove padding */
    }

    .grid-cell {
        font-size: 14px;
        border-width: 1px;
        width: 70px; /* Explicitly set width (Mobile) */
        height: 70px; /* Explicitly set height (Mobile) */
    }

    .control-group {
        margin-bottom: 0.8rem;
    }

    .control-group input {
        font-size: 16px; /* Prevent zoom on mobile */
        padding: 8px;
    }

    .control-group label {
        font-size: 0.9rem;
    }

    .trait-text, .advice-text {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .results p {
        margin: 0.3rem 0;
    }

    .results small {
        display: block;
        margin-top: 2px;
    }

    footer {
        margin-top: 2rem;
        font-size: 0.8rem;
    }
}
