/* ==========================================================================
   Calculate Yield & Revenue Tool Stylesheet - ชัยพฤกษ์เกษตร
   ========================================================================== */

/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Sarabun", sans-serif;
    background-color: #f9fafb;
    color: #374151;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Utilities */
.hidden {
    display: none !important;
}

.max-width-container {
    max-width: 56rem;
    /* 896px (max-w-4xl) */
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Header Section */
.app-header {
    background: linear-gradient(135deg, #16a34a, #047857);
    color: #ffffff;
    text-align: center;
    padding: 2rem 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: 0.025em;
}

@media (min-width: 768px) {
    .app-header h1 {
        font-size: 1.875rem;
    }
}

.app-header p {
    color: #d1fae5;
    font-size: 0.875rem;
    font-weight: 300;
}

/* Main Content Wrapper */
.app-main {
    flex-grow: 1;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* Top Actions & Capture Control */
.top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
    margin-bottom: 1.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #16a34a;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: #15803d;
}

.btn-capture {
    background-color: #f59e0b;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: background-color 0.2s ease;
}

.btn-capture:hover {
    background-color: #d97706;
}

/* Capture Alert Message */
.capture-alert {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.capture-alert .alert-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.capture-alert .alert-content i {
    color: #d97706;
    font-size: 1rem;
}

.btn-exit-capture {
    font-size: 0.75rem;
    font-weight: 700;
    background-color: #ffffff;
    color: #b45309;
    border: 1px solid #fde68a;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-exit-capture:hover {
    background-color: #fef3c7;
}

/* Grid Layout System */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Left Panel: Inputs Container */
.input-panel {
    background-color: #ffffff;
    border-radius: 1rem;
    border: 1px solid #f3f4f6;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: #16a34a;
}

/* Form Styling */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-label {
    display: block;
    font-weight: 600;
    color: #374151;
    font-size: 0.75rem;
}

.input-control {
    width: 100%;
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    color: #1f2937;
    font-size: 0.875rem;
    border: 1px solid #e5e7eb;
    background-color: #f9fafb;
    transition: all 0.2s ease;
}

.input-control:focus {
    outline: none;
    border-color: #16a34a;
    background-color: #ffffff;
}

.input-control-bold {
    font-weight: 700;
}

.input-with-badge {
    position: relative;
}

.input-with-badge .input-control {
    padding-right: 4rem;
}

.input-badge {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.75rem;
    pointer-events: none;
}

/* Right Panel: Invoice Results */
.result-panel {
    background-color: #ffffff;
    border-radius: 1rem;
    border: 1px solid #d1fae5;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: all 0.3s ease;
}

.invoice-header {
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invoice-title h4 {
    font-size: 1.125rem;
    font-weight: 800;
    color: #065f46;
}

.invoice-title p {
    font-size: 0.875rem;
    font-weight: 700;
    color: #4b5563;
    margin-top: 0.125rem;
}

.brand-badge {
    background-color: #d1fae5;
    color: #065f46;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

/* Summary Grid (Top Stats) */
.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    text-align: center;
}

.stat-box {
    background-color: #f9fafb;
    border: 1px solid #f3f4f6;
    padding: 0.75rem;
    border-radius: 0.75rem;
}

.stat-box .label {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.125rem;
}

.stat-box .val {
    font-size: 1.125rem;
    font-weight: 700;
    color: #374151;
}

/* Weight Display Card */
.weight-card {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border: 1px solid #d1fae5;
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.weight-card .label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #065f46;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.weight-card .display-group {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
}

.weight-card .main-weight {
    font-size: 1.875rem;
    font-weight: 900;
    color: #047857;
}

.weight-card .unit {
    font-size: 0.875rem;
    font-weight: 700;
    color: #059669;
}

.weight-card .sub-weight-info {
    text-align: right;
    font-size: 0.75rem;
    color: #6b7280;
}

.weight-card .sub-weight-info span {
    font-weight: 700;
    color: #374151;
}

/* Total Revenue Card (Hero Element) */
.revenue-card {
    background: linear-gradient(135deg, #059669, #0f766e);
    color: #ffffff;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.revenue-card .bg-icon {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.1;
    font-size: 6rem;
}

.revenue-card .label {
    font-size: 0.75rem;
    color: #d1fae5;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.revenue-card .value-group {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.revenue-card .main-revenue {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #fde047;
}

.revenue-card .unit {
    font-size: 1.125rem;
    font-weight: 500;
    color: #d1fae5;
}

/* Invoice Footer Documentation */
.invoice-footer {
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px dashed #e5e7eb;
    padding-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invoice-footer .company-name {
    font-weight: 300;
}

/* Footer Element */
.app-footer {
    background-color: #1f2937;
    color: #9ca3af;
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    border-top: 1px solid #374151;
}

/* Grid Screen Breakpoints */
@media (min-width: 768px) {
    .tool-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .input-panel {
        grid-column: span 2 / span 2;
    }

    .result-panel {
        grid-column: span 3 / span 3;
    }
}

/* ==========================================================================
   Screenshot Optimization Mode Rules
   ========================================================================== */
.screenshot-mode .no-capture {
    display: none !important;
}

.screenshot-mode .result-panel {
    grid-column: span 5 / span 5 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    border-color: #6ee7b7 !important;
}