/* ==========================================
   Agri Price Web - Styles
   Based on agri-price-calculator.html design
   ========================================== */

:root {
    --green-dark: #1a4d2e;
    --green-mid: #2d6a4f;
    --green-light: #40916c;
    --green-pale: #95d5b2;
    --cream: #fefae0;
    --cream-dark: #e9e5cc;
    --orange: #f77f00;
    --orange-light: #fcbf49;
    --brown: #6b4423;
    --text-dark: #1a1a1a;
    --text-mid: #4a4a4a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: var(--cream);
    color: var(--text-dark);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(64, 145, 108, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(247, 127, 0, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 60% 80%, rgba(45, 106, 79, 0.05) 0%, transparent 45%);
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

/* ==========================================
   Header
   ========================================== */
.header {
    text-align: center;
    padding: 24px 0 16px;
}

.header-home {
    padding: 32px 0 24px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--text-mid);
    margin-bottom: 12px;
}

.breadcrumb a {
    color: var(--green-mid);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    margin: 0 6px;
    opacity: 0.5;
}

.header h1 {
    font-family: 'Prompt', sans-serif;
    font-weight: 800;
    font-size: 24px;
    color: var(--green-dark);
    line-height: 1.3;
}

.header .location,
.header .subtitle {
    font-size: 15px;
    color: var(--text-mid);
    margin-top: 4px;
}

/* ==========================================
   Price Card
   ========================================== */
.price-card {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
    border-radius: 20px;
    padding: 28px 24px;
    margin: 16px 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(26, 77, 46, 0.25);
}

.price-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.price-card::after {
    content: var(--product-icon, '🌾');
    position: absolute;
    bottom: 10px;
    right: 16px;
    font-size: 48px;
    opacity: 0.15;
}

.price-label {
    font-size: 14px;
    color: var(--green-pale);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.product-type {
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    margin-bottom: 8px;
    font-weight: 500;
}

.price-main {
    font-family: 'Prompt', sans-serif;
    font-size: 56px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.price-main .unit {
    font-size: 20px;
    font-weight: 500;
    opacity: 0.8;
    margin-left: 4px;
}

.price-range {
    font-size: 16px;
    color: var(--orange-light);
    margin-top: 8px;
    font-weight: 600;
}

.price-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.15);
    position: relative;
    z-index: 1;
}

.update-time {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
}

.price-change {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.15);
    padding: 4px 10px;
    border-radius: 20px;
}

.price-change.down {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

.price-change.unchanged {
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.1);
}

/* Estimated Badge */
.estimated-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.2);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}


.price-note {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    margin-top: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
}

/* ==========================================
   Calculator Card
   ========================================== */
.calc-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    margin: 16px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
}

.calc-title {
    font-family: 'Prompt', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--green-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group {
    margin-bottom: 16px;
}

.input-label {
    font-size: 14px;
    color: var(--text-mid);
    margin-bottom: 8px;
    display: block;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 16px 60px 16px 20px;
    font-size: 24px;
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    border: 2px solid var(--cream-dark);
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
    background: var(--cream);
}

.input-wrapper input:focus {
    border-color: var(--green-light);
    background: #fff;
}

.input-wrapper .input-unit {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-mid);
}

/* Presets */
.presets {
    margin-bottom: 20px;
}

.presets-label {
    font-size: 13px;
    color: var(--text-mid);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preset-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-btn {
    flex: 1;
    min-width: calc(50% - 4px);
    padding: 12px 8px;
    border: 2px solid var(--cream-dark);
    background: var(--cream);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--green-light);
    background: rgba(64, 145, 108, 0.05);
}

.preset-btn.active {
    border-color: var(--green-mid);
    background: rgba(64, 145, 108, 0.1);
}

.preset-btn .preset-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.preset-btn .preset-name {
    font-size: 12px;
    color: var(--text-mid);
    display: block;
}

.preset-btn .preset-value {
    font-family: 'Prompt', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--green-dark);
}

/* Result */
.result {
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.result::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.08'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.result-label {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
    margin-bottom: 8px;
    position: relative;
}

.result-value {
    font-family: 'Prompt', sans-serif;
    font-size: 40px;
    font-weight: 800;
    color: #fff;
    position: relative;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.result-value .currency {
    font-size: 24px;
    font-weight: 600;
}

.result-formula {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    margin-top: 8px;
    position: relative;
}

/* ==========================================
   Chart Section
   ========================================== */
.chart-section {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    margin: 16px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
}

.chart-title {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    margin-bottom: 16px;
}

/* Chart Canvas Wrapper */
.chart-canvas-wrapper {
    height: 200px;
    position: relative;
}

/* Stats */
.chart-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--cream-dark);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-family: 'Prompt', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--green-dark);
}

.stat-value.up {
    color: #059669;
}

.stat-value.down {
    color: #dc2626;
}

.stat-label {
    font-size: 12px;
    color: var(--text-mid);
}

/* Chart Legend */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--cream-dark);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-mid);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.solid {
    background: var(--green-dark);
}

.legend-dot.hollow {
    background: #fff;
    border: 2px solid #9ca3af;
}

/* ==========================================
   Price History Table
   ========================================== */
.price-table-section {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    margin: 16px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.table-title {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    margin: 0;
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--green-dark);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Sarabun', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-download:hover {
    background: var(--green-light);
    transform: translateY(-1px);
}

.btn-download:active {
    transform: translateY(0);
}

.btn-download svg {
    flex-shrink: 0;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.price-table th,
.price-table td {
    padding: 12px 8px;
    text-align: right;
    border-bottom: 1px solid var(--cream-dark);
}

.price-table th {
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    color: var(--text-mid);
    background: var(--cream);
    position: sticky;
    top: 0;
}

.price-table th:first-child,
.price-table td:first-child {
    text-align: left;
}

.price-table tbody tr:hover {
    background: rgba(45, 106, 79, 0.05);
}

.price-table tbody tr.today {
    background: rgba(45, 106, 79, 0.1);
    font-weight: 600;
}

.price-table tbody tr.today td {
    color: var(--green-dark);
}

.price-table tbody tr.estimated {
    color: var(--text-mid);
}

.price-table .date-cell {
    white-space: nowrap;
    font-weight: 500;
}

.price-table .price-cell {
    font-family: 'Prompt', sans-serif;
    font-weight: 500;
}

.price-table .price-cell.min {
    color: #dc2626;
}

.price-table .price-cell.avg {
    color: var(--green-dark);
}

.price-table .price-cell.max {
    color: #059669;
}

.price-table .note-cell {
    color: var(--text-mid);
    font-size: 12px;
}

/* ==========================================
   Info Section
   ========================================== */
.info-section {
    background: #fff;
    border-radius: 20px;
    padding: 20px 24px;
    margin: 16px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--cream-dark);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 14px;
    color: var(--text-mid);
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

/* ==========================================
   Factories Section
   ========================================== */
.factories-section {
    background: #fff;
    border-radius: 20px;
    padding: 20px 24px;
    margin: 16px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
}

.section-title {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    margin-bottom: 16px;
}

.factories-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.factory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--cream);
    border-radius: 10px;
}

.factory-info {
    display: flex;
    flex-direction: column;
}

.factory-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.factory-location {
    font-size: 12px;
    color: var(--text-mid);
}

.factory-price {
    font-family: 'Prompt', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--green-dark);
}

/* ==========================================
   Provinces & Districts Grid
   ========================================== */
.provinces-section,
.districts-section {
    margin: 24px 0;
}

.provinces-grid,
.districts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.province-link,
.district-link {
    padding: 10px 16px;
    background: #fff;
    border: 1px solid var(--cream-dark);
    border-radius: 10px;
    font-size: 14px;
    color: var(--green-mid);
    text-decoration: none;
    transition: all 0.2s ease;
}

.province-link:hover,
.district-link:hover {
    background: var(--green-mid);
    color: #fff;
    border-color: var(--green-mid);
}

.district-count {
    font-size: 12px;
    color: var(--text-mid);
    margin-left: 4px;
}

.province-link:hover .district-count {
    color: rgba(255,255,255,0.8);
}

/* ==========================================
   Nearby Section
   ========================================== */
.nearby-section {
    margin: 24px 0;
}

.nearby-title {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    margin-bottom: 12px;
}

.nearby-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nearby-link {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid var(--cream-dark);
    border-radius: 20px;
    font-size: 13px;
    color: var(--green-mid);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nearby-link:hover {
    background: var(--green-mid);
    color: #fff;
    border-color: var(--green-mid);
}

/* ==========================================
   Products Grid (Home)
   ========================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.product-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px 16px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
    transition: all 0.2s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    border-color: var(--green-light);
}

.product-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.product-name {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    margin-bottom: 8px;
}

.product-price {
    margin-bottom: 4px;
}

.product-price .price-value {
    font-family: 'Prompt', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: var(--orange);
}

.product-price .price-unit {
    font-size: 12px;
    color: var(--text-mid);
}

.product-date {
    font-size: 11px;
    color: var(--text-mid);
}

/* ==========================================
   Info Box
   ========================================== */
.info-box {
    background: #fff;
    border-radius: 16px;
    padding: 20px 24px;
    margin: 24px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid var(--cream-dark);
}

.info-box h3 {
    font-family: 'Prompt', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
    margin-bottom: 12px;
}

.info-box p {
    font-size: 14px;
    color: var(--text-mid);
    margin-bottom: 12px;
    line-height: 1.6;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    font-size: 14px;
    color: var(--text-mid);
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
}

.info-box li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--green-mid);
}

/* ==========================================
   Disclaimer
   ========================================== */
.disclaimer {
    font-size: 12px;
    color: var(--text-mid);
    text-align: center;
    padding: 16px;
    line-height: 1.6;
    opacity: 0.8;
}

/* ==========================================
   Footer
   ========================================== */
.footer {
    text-align: center;
    padding: 32px 16px;
    font-size: 13px;
    color: var(--text-mid);
}

.footer a {
    color: var(--green-mid);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer-links {
    margin: 8px 0;
}

.copyright {
    margin-top: 8px;
    opacity: 0.7;
}

/* ==========================================
   Animations
   ========================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.price-card,
.calc-card,
.chart-section,
.info-section,
.factories-section,
.product-card {
    animation: fadeInUp 0.5s ease forwards;
}

.calc-card { animation-delay: 0.1s; }
.chart-section { animation-delay: 0.2s; }
.info-section { animation-delay: 0.3s; }

/* ==========================================
   Responsive
   ========================================== */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .price-main {
        font-size: 64px;
    }
}
