/* =============================================
   MywayD - Modal Fix CSS
   เพิ่มไฟล์นี้ต่อท้าย style.css หรือ link แยก
   ============================================= */

/* Reset Modal - ซ่อนทั้งหมดตอนเริ่มต้น */
.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

/* Modal เมื่อเปิด (ใช้ class .show) */
.modal.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Modal Handle */
.modal-handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 4px;
    margin: 12px auto;
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #6b7280;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #e5e7eb;
}

/* Modal Body */
.modal-body {
    padding: 16px;
}

/* Form Row - 2 columns */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* =============================================
   Quality Buttons (Sleep)
   ============================================= */
.quality-buttons {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.quality-btn {
    flex: 1;
    padding: 12px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    font-size: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.quality-btn:hover {
    border-color: #0d9488;
    background: #f0fdfa;
}

.quality-btn.active {
    border-color: #0d9488;
    background: #ccfbf1;
}

.quality-btn small {
    display: block;
    font-size: 0.7rem;
    color: #6b7280;
    margin-top: 4px;
}

/* =============================================
   Meal Type Buttons (Food)
   ============================================= */
.meal-type-buttons {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.meal-type-btn {
    flex: 1;
    padding: 12px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    font-size: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.meal-type-btn:hover {
    border-color: #f59e0b;
    background: #fffbeb;
}

.meal-type-btn.active {
    border-color: #f59e0b;
    background: #fef3c7;
}

.meal-type-btn small {
    display: block;
    font-size: 0.7rem;
    color: #6b7280;
    margin-top: 4px;
}

/* =============================================
   Toast Notifications
   ============================================= */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 12px;
    background: #1f2937;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #059669;
}

.toast-error {
    background: #dc2626;
}

.toast-info {
    background: #0891b2;
}

/* =============================================
   Form Controls Fix
   ============================================= */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #6b7280;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #0d9488;
}

/* Button */
.btn-primary {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #0d9488, #0891b2);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 1.1rem;
}

/* Button Group for Activity Modals */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.button-group .btn-option {
    flex: 1 1 auto;
    min-width: calc(33% - 0.5rem);
    padding: 0.6rem 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
}

.button-group .btn-option:hover {
    border-color: #0d9488;
    background: #f0fdfa;
}

.button-group .btn-option.active {
    border-color: #0d9488;
    background: linear-gradient(135deg, #0d9488, #0891b2);
    color: white;
}

/* Rating Buttons */
.rating-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.rating-buttons .rating-btn {
    flex: 1;
    padding: 0.6rem 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
}

.rating-buttons .rating-btn:hover {
    border-color: #06b6d4;
    background: #f0fdfa;
}

.rating-buttons .rating-btn.active {
    border-color: #06b6d4;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

/* Quick Tags */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 2rem;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.tag-btn:hover {
    border-color: #f97316;
    background: #fff7ed;
}

/* Distance Controls */
.distance-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dist-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dist-btn:hover {
    border-color: #f97316;
    background: #fff7ed;
}

.dist-btn:active {
    transform: scale(0.95);
}

.distance-input {
    flex: 1;
    text-align: center;
    font-size: 1.5rem !important;
    font-weight: 600 !important;
    padding: 0.75rem !important;
}

/* Form Row */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* Required Indicator */
.required {
    color: #ef4444;
}

/* Info Box */
.info-box {
    background: #f0fdf4;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Textarea */
textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Select Styling */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* =============================================
   Voice Input Button - ปุ่มไมค์สำหรับ Modal
   ============================================= */

/* Input with Voice wrapper */
.input-with-voice {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.input-with-voice .form-control {
    flex: 1;
    padding-right: 1rem;
}

/* Voice Button */
.voice-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn:hover {
    border-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    transform: scale(1.05);
}

.voice-btn:active {
    transform: scale(0.95);
}

/* Voice Button Active State (listening) */
.voice-btn.listening {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    animation: pulse-voice 1.5s ease-in-out infinite;
}

@keyframes pulse-voice {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Textarea with Voice */
.textarea-voice {
    align-items: flex-start;
}

.textarea-voice .voice-btn {
    margin-top: 0;
}

/* Small screens - larger touch target */
@media (max-width: 480px) {
    .voice-btn {
        width: 52px;
        height: 52px;
        min-width: 52px;
        font-size: 1.4rem;
    }
}

/* =============================================
   Mood Modal Styles
   ============================================= */

/* Mood Picker - 5 emoji buttons */
.mood-picker {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.mood-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mood-btn .emoji {
    font-size: 1.75rem;
}

.mood-btn .label {
    font-size: 0.7rem;
    color: #6b7280;
}

.mood-btn:hover {
    border-color: #ec4899;
    background: #fce7f3;
}

.mood-btn.active {
    border-color: #ec4899;
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.3);
}

.mood-btn.active .emoji {
    transform: scale(1.2);
}

/* Mood Type Section */
.mood-type-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mood-type-group {
    background: #f9fafb;
    border-radius: 12px;
    padding: 0.75rem;
}

.mood-type-group .group-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

.mood-type-group .group-label.positive {
    color: #10b981;
}

.mood-type-group .group-label.negative {
    color: #6b7280;
}

.mood-type-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mood-type-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 2rem;
    background: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mood-type-btn:hover {
    border-color: #ec4899;
    background: #fce7f3;
}

.mood-type-btn.active {
    border-color: #ec4899;
    background: #ec4899;
    color: white;
}

/* Energy Slider */
.energy-slider {
    padding: 0.5rem 0;
}

.energy-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.form-range {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #fecaca 0%, #fef3c7 25%, #d1fae5 50%, #a7f3d0 75%, #6ee7b7 100%);
    -webkit-appearance: none;
    appearance: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid #ec4899;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.form-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid #ec4899;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.energy-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.energy-display .energy-icon {
    font-size: 1.5rem;
}

/* Factors Grid */
.factors-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.factor-btn {
    padding: 0.5rem 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 2rem;
    background: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.factor-btn:hover {
    border-color: #ec4899;
    background: #fce7f3;
}

.factor-btn.active {
    border-color: #ec4899;
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #be185d;
    font-weight: 500;
}
