/**
 * 부고장 시스템 - 모바일 최적화 스타일
 * Mobile First Design
 */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
}

*::-webkit-scrollbar {
    display: none;
}

/* Container */
.container {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    background-color: #fff;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
.header {
    padding: 40px 20px 20px;
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.flower-decoration {
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
    opacity: 0.8;
}

.flower-decoration svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: #666;
    stroke-width: 1;
}

.title {
    font-size: 2.5rem;
    font-weight: 300;
    color: #2c3e50;
    margin-bottom: 20px;
    letter-spacing: 6px;
}

.subtitle {
    font-size: 1rem;
    color: #666;
    margin-bottom: 30px;
}

/* Form Styles */
.form-container {
    padding: 30px 20px;
}

.form-section {
    margin-bottom: 40px;
    background-color: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f0;
}

.section-title {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

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

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-label.required::after {
    content: " *";
    color: #e74c3c;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    color: #333;
    background-color: #fff;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #666;
    box-shadow: 0 0 0 3px rgba(102,102,102,0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23666' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

/* Dynamic Fields */
.dynamic-fields {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.dynamic-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.field-title {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.remove-field-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-field-btn:hover {
    background-color: #ffeaea;
}

.add-field-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    color: #666;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-field-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

/* Date & Time Inputs */
.datetime-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.date-input {
    flex: 1;
    min-width: 0;
}

.date-input input[type="date"] {
    width: 100%;
    box-sizing: border-box;
}

.time-input {
    flex: 1;
    min-width: 0;
    position: relative;
}

.time-input input[type="time"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background-color: #fff;
    color: #333;
    min-width: 0;
    box-sizing: border-box;
}

/* 시간 입력 필드가 비어있을 때 "시간" 힌트 표시 */
.time-input::before {
    content: '시간';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
    background: #fff;
    padding: 0 2px;
}

/* 시간 입력 필드에 값이 있거나 포커스되면 힌트 숨김 */
.time-input.has-value::before,
.time-input.has-focus::before {
    display: none;
}

.time-input input[type="time"]:focus {
    border-color: #4a4a4a;
    outline: none;
}

.time-input input[type="time"]:invalid {
    border-color: #ddd;
}

/* 모바일에서 레이아웃 안정화 */
@media (max-width: 768px) {
    .datetime-group {
        flex-wrap: nowrap;
        align-items: center;
    }
    
    .date-input,
    .time-input {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
    }
    
    .time-input input[type="time"] {
        font-size: 15px;
        padding: 12px;
    }
    
    .time-input::before {
        font-size: 15px;
        left: 12px;
    }
}

/* Custom Relation Input */
.custom-relation-input {
    margin-top: 10px;
    display: none;
}

.custom-relation-input.show {
    display: block;
}

/* Address Search */
.address-input-group {
    position: relative;
}

.address-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #666;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.address-search-btn:hover {
    background-color: #555;
}

.address-input {
    padding-right: 80px !important;
    cursor: pointer;
}

/* Error States */
.form-input.error,
.form-textarea.error,
.form-select.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

.error-message {
    font-size: 0.8rem;
    color: #e74c3c;
    margin-top: 5px;
}

/* Toast Popup */
.toast {
    position: fixed;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #e74c3c;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(231,76,60,0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(10px);
}

.toast.warning {
    background-color: #f39c12;
    box-shadow: 0 4px 12px rgba(243,156,18,0.3);
}

.toast.success {
    background-color: #27ae60;
    box-shadow: 0 4px 12px rgba(39,174,96,0.3);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    padding: 20px;
    position: sticky;
    bottom: 0;
    background-color: #fff;
    border-top: 1px solid #e9ecef;
    z-index: 100;
}

.btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: #2c3e50;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1a252f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44,62,80,0.25);
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background-color: transparent;
    color: #666;
    border: 1px solid #ddd;
}

.btn-outline:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
}

/* Help Text */
.help-text {
    font-size: 0.8rem;
    color: #888;
    margin-top: 5px;
    line-height: 1.4;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #666;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Footer */
.footer {
    background-color: #f8f9fa;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #e9ecef;
}

.footer-text {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 5px;
}

.footer-copyright {
    font-size: 0.7rem;
    color: #ccc;
}

/* Style Selector */
.style-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.style-option {
    display: block;
    cursor: pointer;
}

.style-option input[type="radio"] {
    display: none;
}

.style-preview {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background-color: #fff;
    transition: all 0.3s ease;
    text-align: center;
}

.style-option input[type="radio"]:checked + .style-preview {
    border-color: #8B7355;
    background-color: #faf8f5;
    box-shadow: 0 2px 8px rgba(139, 115, 85, 0.2);
}

.preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.preview-content {
    font-size: 0.75rem;
    line-height: 1.6;
    color: #666;
}

.preview-name {
    font-weight: 500;
    margin-bottom: 5px;
}

.preview-date {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 5px;
}

.preview-message {
    font-size: 0.7rem;
    color: #999;
    margin-top: 5px;
}

/* Style Previews */
.classic-preview {
    font-family: "Noto Serif KR", serif;
}

.modern-preview {
    font-family: "Noto Sans KR", sans-serif;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.elegant-preview {
    font-family: "Noto Serif KR", serif;
    font-style: italic;
    letter-spacing: 1px;
}

.simple-preview {
    font-family: "Noto Sans KR", sans-serif;
    font-weight: 400;
}

@media (max-width: 360px) {
    .style-selector {
        grid-template-columns: 1fr;
    }
}


/* Responsive */
@media screen and (max-width: 360px) {
    .form-container {
        padding: 20px 15px;
    }
    
    .form-section {
        padding: 20px 15px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .button-group {
        flex-direction: column;
        padding: 15px;
    }
    
    .toast {
        top: 10px;
        max-width: 95%;
        font-size: 0.85rem;
        padding: 10px 16px;
    }
    
    .title {
        font-size: 2rem;
    }
}

