/* --- 1. ตั้งค่าพื้นฐาน (Design System Concept) --- */
:root {
    /* Color Palette (Premium Earth Tones) */
    --bg-color: #F5F7F5;         /* Off-White นวลตาสบายใจ */
    --card-bg: #E7EFE9;          /* Pastel Green สดชื่น */
    --text-dark: #222E26;        /* เขียวเข้มสตรีทเกือบดำ เพื่อให้อ่านง่าย */
    --accent-sage: #4B6B55;      /* เขียวใบเสจ สวยสุขุม */
    --accent-light: #F0F4F1;     /* เขียวอ่อนพาสเทลจาง */
    --white: #FFFFFF;
    
    /* Visual Effects */
    --radius-xl: 32px;           /* ขอบโค้งมนดีไซเนอร์ */
    --radius-md: 20px;
    --shadow-premium: 0 16px 40px rgba(34, 46, 38, 0.05); /* เงานุ่มนวลฟุ้งเบาบาง */
    --shadow-hover: 0 24px 48px rgba(75, 107, 85, 0.12);
    
    font-family: 'Prompt', sans-serif;
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.6;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* Header */
.dashboard-header {
    text-align: center;
    margin-bottom: 4rem;
}

.header-tag {
    display: inline-block;
    background: var(--card-bg);
    color: var(--accent-sage);
    padding: 0.3rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.8;
}

/* --- 2. Grid Layout & Cards --- */
.farm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2.5rem;
}

.greenhouse-section {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-premium);
    border: 1px solid rgba(75, 107, 85, 0.05);
}

.greenhouse-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--bg-color);
}

.tables-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
}

/* โครงสร้างการ์ดโต๊ะปลูกดีไซน์พรีเมียม */
.table-card {
    background: var(--accent-light);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
}

.table-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    background: var(--white);
    border-color: rgba(75, 107, 85, 0.15);
}

.table-card-left {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

/* รูปหน้าปกผักย่อขนาดในการ์ดหลัก */
.crop-thumbnail-small {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.table-card-info {
    display: flex;
    flex-direction: column;
}

.table-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
}

.crop-name {
    font-size: 0.9rem;
    color: var(--accent-sage);
}

.harvest-countdown {
    font-size: 0.8rem;
    background: var(--white);
    color: var(--text-dark);
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

/* สถานะโต๊ะปลูกเพื่อเปลี่ยนโทนสี */
.status-empty { background-color: #F0F2F0; opacity: 0.8; }
.status-empty .crop-name { color: #8c968f; }

.status-planting { background-color: var(--accent-light); }

.status-harvesting { 
    background-color: #E8F5E9; 
    border: 1px dashed #2E7D32;
}
.status-harvesting .harvest-countdown {
    background: #2E7D32;
    color: var(--white);
}

/* --- 3. Premium Glassmorphism Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(34, 46, 38, 0.4); 
    backdrop-filter: blur(12px); /* ฝ้ากระจกเบลอมากขึ้นเพื่อความหรูหรา */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
    display: none;
    pointer-events: none;
}

.modal-content {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    width: 92%;
    max-width: 520px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.12);
    position: relative;
    max-height: 90vh;
    overflow-y: auto; /* เผื่อหน้าจอมือถือเตี้ย */
}

.close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-dark);
    opacity: 0.4;
    transition: opacity 0.2s;
}
.close-btn:hover { opacity: 1; }

.modal-header-section {
    margin-bottom: 2rem;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--accent-sage);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

/* ฟอร์ม */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-group label {
    font-size: 0.95rem;
    font-weight: 600;
}

.form-group select,
.form-group input {
    padding: 1rem 1.2rem;
    border: 1px solid rgba(75, 107, 85, 0.15);
    border-radius: 18px;
    font-size: 1rem;
    outline: none;
    background: var(--bg-color);
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group select:focus,
.form-group input:focus {
    border-color: var(--accent-sage);
    background: var(--white);
}

/* 🌟 ส่วนหัวของข้อมูลผักใน Modal (เหมือนในรูปภาพอ้างอิง) */
.crop-header-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-color);
    padding: 1.2rem;
    border-radius: var(--radius-md);
}

.crop-thumbnail-large {
    width: 90px;
    height: 90px;
    border-radius: 24px;
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.crop-header-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.tag-growing {
    display: inline-block;
    align-self: flex-start;
    background: #E8F5E9;
    color: #2E7D32;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.crop-name-title {
    font-size: 1.3rem;
    font-weight: 600;
}

.planting-date-text {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* 🌟 Dynamic Progress Bar */
.progress-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
}

.progress-percent-number {
    color: var(--accent-sage);
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 10px;
    background: var(--bg-color);
    border-radius: 50px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-sage), #689f78);
    border-radius: 50px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 🌟 Premium Progress Timeline (สไตล์ Progress Plants) */
.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-header-text {
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.9;
}

.progress-timeline {
    position: relative;
    padding-left: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* เส้นเชื่อมไทม์ไลน์แนวตั้ง */
.progress-timeline::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: #E0E0E0;
}

.timeline-item {
    position: relative;
}

.timeline-badge {
    position: absolute;
    left: -2rem;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #E0E0E0;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.3s;
    z-index: 2;
}

.timeline-content {
    display: flex;
    flex-direction: column;
}

.timeline-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #999;
    transition: color 0.3s;
}

.timeline-desc {
    font-size: 0.75rem;
    color: #999;
}

/* สถานะเมื่อขั้นตอนเสร็จสิ้น (Active Step) */
.timeline-item.active .timeline-badge {
    background: var(--accent-sage);
    box-shadow: 0 0 0 4px rgba(75, 107, 85, 0.15);
}

.timeline-item.active .timeline-title {
    color: var(--text-dark);
}

.timeline-item.active .timeline-desc {
    color: var(--accent-sage);
}

/* กล่องพยากรณ์ข้อมูลในฟอร์ม */
.forecast-box {
    background: var(--bg-color);
    padding: 1.2rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(75, 107, 85, 0.1);
}

.forecast-title { font-weight: 600; font-size: 0.9rem; }
.forecast-season { font-size: 0.85rem; color: var(--accent-sage); margin-bottom: 0.6rem;}
.forecast-result { font-size: 0.95rem; }
.forecast-days { display: block; font-size: 0.8rem; color: #666; margin-top: 0.1rem; }

/* ปุ่มกดพรีเมียม */
.btn {
    padding: 1.1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-primary { background: var(--text-dark); color: white; }
.btn-primary:hover { background: #131b16; }

.btn-success { background: var(--accent-sage); color: white; }
.btn-success:hover { background: #3c5644; }

/* Utilities */
.hidden { display: none !important; }

.loading-card {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--accent-sage);
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-premium);
}