/* Apple Style Reset & Defaults */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    background-color: #f5f5f7; /* Apple-like light gray */
    color: #1d1d1f; /* Apple-like dark gray for text */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header */
header {
    background-color: #ffffff;
    padding: 1rem 0;
    text-align: center;
    border-bottom: 1px solid #d2d2d7;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0;
}

/* Main Navigation Menu in Header */
.main-nav {
    text-align: center;
    margin-top: 0.5rem; /* Space below h1 */
}

.nav-item {
    display: inline-block; /* Allow padding and spacing */
    padding: 0.5rem 1rem;
    margin: 0 0.5rem;
    color: #007aff; /* Apple blue */
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 2px solid transparent; /* For active state indicator */
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

.nav-item:hover {
    color: #005ecb; /* Darker blue on hover */
}

.nav-item.active {
    color: #1d1d1f; /* Darker text for active tab */
    border-bottom-color: #007aff; /* Blue underline for active tab */
    font-weight: 600;
}

/* Main Content Area */
main {
    max-width: 720px; /* Slightly narrower for better readability */
    margin: 2.5rem auto;
    padding: 0 1.5rem; /* Padding on sides */
    background-color: transparent; /* Remove white background from main */
    box-shadow: none; /* Remove shadow from main */
}

/* Sections */
section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #ffffff; /* White background for sections */
    border: none; /* Remove border */
    border-radius: 12px; /* Increased rounding */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

section h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 0;
    border-bottom: none; /* Remove border */
}

/* Options (Radio Buttons) */
.options label {
    margin-right: 1.5rem;
    cursor: pointer;
    display: inline-flex; /* Align items */
    align-items: center;
    gap: 0.5rem; /* Space between radio and text */
}

/* Input Area & File Upload */
.input-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Input Methods Container for side-by-side layout */
.input-methods {
    display: flex;
    flex-direction: row; /* Arrange items horizontally */
    align-items: center; /* Align items vertically in the center */
    gap: 1rem; /* Space between the upload button and camera button */
}

/* Ensure the custom file upload and button take appropriate width */
.input-methods .custom-file-upload,
.input-methods #camera-btn {
    flex-grow: 1; /* Allow them to grow and share space */
    /* Or assign specific widths if needed, e.g., width: 50%; */
}

input[type="file"] {
    display: none;
}

/* Style the label to look like a button */
.custom-file-upload {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    color: #007aff; /* Apple blue */
    background-color: #f5f5f7;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.custom-file-upload:hover {
    background-color: #e8e8ed;
    border-color: #c7c7cc;
}

/* Buttons */
button {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    color: #ffffff;
    background-color: #007aff; /* Apple blue for primary buttons */
}

button:hover {
    background-color: #005ecb; /* Darker blue on hover */
}

button:disabled {
    background-color: #d2d2d7;
    color: #8e8e93;
    cursor: not-allowed;
}

/* Specific Button Styling */
#camera-btn {
    background-color: #6c757d; /* Gray for secondary actions */
}

#camera-btn:hover {
    background-color: #5a6268;
}

/* Container for the submit problem button to center it */
.submit-problem-container {
    text-align: center;
    margin-top: 1rem; /* Add some space above the button */
}

.instructions {
    font-size: 0.9em;
    color: #636366; /* Slightly lighter gray */
    text-align: center;
    margin-top: 0.5rem;
}

/* Image Preview */
#image-preview-container {
    margin-top: 1.5rem;
    text-align: center;
}

#image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid #d2d2d7;
    object-fit: contain;
}

/* Textarea */
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    box-sizing: border-box;
    resize: vertical;
    font-family: inherit;
    font-size: 1rem;
    background-color: #f5f5f7;
    min-height: 100px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: #007aff;
    background-color: #ffffff;
}

/* Loading Indicators */
.loading {
    text-align: center;
    padding: 1.5rem;
    color: #636366;
    font-style: normal;
    font-size: 0.95rem;
    background-color: #f5f5f7;
    border-radius: 8px;
}

/* Solution Result Area */
#solution-result {
    border: none; /* Remove border */
    padding: 1.5rem;
    margin-top: 1.5rem;
    background-color: #f5f5f7;
    border-radius: 8px;
}

#answer-area {
    margin-bottom: 1rem;
    font-size: 1.1em;
    font-weight: 500;
}

#answer-area strong {
    color: #1d1d1f;
}

/* Details/Summary for Explanation */
details {
    margin-top: 1rem;
}

details summary {
    cursor: pointer;
    font-weight: 500;
    color: #007aff;
    padding: 0.5rem 0;
    list-style: none; /* Remove default marker */
    display: inline-block; /* Prevent full width */
    transition: color 0.2s ease;
}

details summary:hover {
    color: #005ecb;
    text-decoration: none;
}

details summary::before {
    content: '▶ ';
    font-size: 0.8em;
    margin-right: 0.3rem;
    display: inline-block;
    transition: transform 0.2s ease-in-out;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

#explanation {
    margin-top: 0.8rem;
    padding-left: 0;
    border-left: none;
    color: #3c3c43; /* Slightly lighter text for explanation */
    line-height: 1.6;
}

/* Container for the save solution button */
.save-solution-container {
    text-align: center;
    margin-top: 1.5rem; /* Add some space above the button */
}

/* Message Areas (Error/Info) */
.message {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.error {
    color: #d70015;
    background-color: #ffebee;
    border: 1px solid #ffcdd2;
}

.info {
    color: #006c70;
    background-color: #e0f7fa;
    border: 1px solid #b2ebf2;
}

.hidden {
    display: none;
}

/* History Link Section */
#history-link {
    text-align: center;
    background-color: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

#view-history {
    color: #007aff;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

#view-history:hover {
    color: #005ecb;
}

/* Footer */
footer {
    text-align: center;
    margin: 3rem auto 1.5rem auto;
    padding: 1rem 0;
    color: #8e8e93; /* Lighter gray for footer */
    font-size: 0.85rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    main {
        margin: 1.5rem auto;
        padding: 0 1rem;
    }

    section {
        padding: 1rem;
        border-radius: 10px;
    }

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

    button, .custom-file-upload {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    textarea {
        padding: 10px;
    }
}

/* Camera Modal */
.modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#camera-video {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 8px;
    background-color: #000;
    margin-bottom: 15px;
}

.modal-controls {
    margin-top: 10px;
}

.modal-controls button {
    margin: 0 10px;
    /* padding: 10px 20px; 기본 버튼 스타일이 이미 존재하므로 이 줄은 중복될 수 있음 */
}

#close-camera-btn {
    background-color: #6c757d;
}
#close-camera-btn:hover {
    background-color: #5a6268;
} 