﻿/* ============================================================
   AgroTrade - Design System
   ============================================================ */

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Base */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    color: #333;
    background: #f5f5f5;
    line-height: 1.6;
}
a { color: #1b5e20; text-decoration: none; }
a:hover { text-decoration: underline; }
.text-muted { color: #888; font-size: 14px; }
strong { font-weight: 600; }
small { font-size: 12px; color: #888; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: #1b5e20; color: white; }
.btn-primary:hover { background: #2e7d32; }
.btn-success { background: #2e7d32; color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: #c62828; color: white; }
.btn-danger:hover { background: #b71c1c; }
.btn-outline { background: white; color: #1b5e20; border: 2px solid #e0e0e0; }
.btn-outline:hover { border-color: #1b5e20; background: #f9f9f9; text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-icon { padding: 6px 10px; font-size: 14px; }

/* ============================================================
   Alerts
   ============================================================ */
.alert { padding: 14px 18px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.alert-danger, .alert-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* ============================================================
   Badges
   ============================================================ */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-success { background: #e8f5e9; color: #1b5e20; }
.badge-danger { background: #ffebee; color: #c62828; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-secondary { background: #f5f5f5; color: #666; }
.badge-primary { background: #e8f5e9; color: #1b5e20; }
/* Harvest status badges */
.badge-planejada { background: #f5f5f5; color: #666; }
.badge-plantada { background: #e8f5e9; color: #1b5e20; }
.badge-colhendo { background: #fff3e0; color: #e65100; }
.badge-colhida { background: #e3f2fd; color: #1565c0; }
.badge-vendida { background: #e8f5e9; color: #1b5e20; }
/* Offer status badges */
.badge-pendente { background: #fff3e0; color: #e65100; }
.badge-aceito { background: #e8f5e9; color: #1b5e20; }
.badge-recusado { background: #ffebee; color: #c62828; }
.badge-contraproposta { background: #e3f2fd; color: #1565c0; }
.badge-expirado { background: #f5f5f5; color: #666; }
/* Deal status badges */
.badge-confirmado { background: #e8f5e9; color: #1b5e20; }
.badge-em_transito { background: #e3f2fd; color: #1565c0; }
.badge-entregue { background: #e8f5e9; color: #1b5e20; }
.badge-pago { background: #e8f5e9; color: #1b5e20; }
.badge-cancelado { background: #ffebee; color: #c62828; }
/* Contract status badges */
.badge-rascunho { background: #f5f5f5; color: #666; }
.badge-aguardando_assinatura { background: #fff3e0; color: #e65100; }
.badge-assinado { background: #e8f5e9; color: #1b5e20; }
/* Solicitacao status badges */
.badge-pendente { background: #fff3e0; color: #e65100; }
.badge-aprovada { background: #e8f5e9; color: #1b5e20; }
.badge-rejeitada { background: #ffebee; color: #c62828; }

/* ============================================================
   Cards
   ============================================================ */
.card { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); overflow: hidden; margin-bottom: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-actions { display: flex; gap: 8px; }
.card-grid { display: grid; gap: 20px; }

/* ============================================================
   Tables
   ============================================================ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.table th { background: #fafafa; font-weight: 600; font-size: 12px; color: #666; text-transform: uppercase; }
.table tbody tr:hover { background: #f9f9f9; }
.table-responsive { overflow-x: auto; }
.table tfoot td { font-weight: 600; background: #fafafa; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; color: #333; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 2px solid #e0e0e0; border-radius: 8px;
    font-size: 15px; transition: border-color 0.2s; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #4caf50; outline: none; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-section { margin-bottom: 24px; }
.form-section h3 { font-size: 16px; font-weight: 600; color: #1b5e20; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid #e8f5e9; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #eee; }
.inline-form { display: inline; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }

/* ============================================================
   Layout App (Sidebar + Main)
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px; background: white; border-right: 1px solid #eee;
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column; z-index: 100;
    transition: transform 0.3s;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid #eee; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; color: #1b5e20; text-decoration: none; }
.sidebar-logo:hover { text-decoration: none; }
.logo-icon { font-size: 28px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    border-radius: 8px; color: #555; text-decoration: none; font-size: 14px;
    font-weight: 500; margin-bottom: 2px; transition: all 0.2s;
}
.nav-item:hover { background: #e8f5e9; color: #1b5e20; text-decoration: none; }
.nav-item.active { background: #1b5e20; color: white; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.nav-divider { height: 1px; background: #eee; margin: 12px 0; }
.nav-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #888; padding: 8px 14px; font-weight: 600; }

.sidebar-footer { padding: 12px; border-top: 1px solid #eee; }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: #1b5e20;
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.user-details .user-name { font-weight: 600; font-size: 13px; }
.user-details .user-role { font-size: 11px; color: #888; }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; background: #f5f5f5; }

/* Topbar */
.topbar {
    height: 60px; background: white; border-bottom: 1px solid #eee;
    display: flex; align-items: center; padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; margin-right: 12px; }
.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.topbar-icon { font-size: 18px; position: relative; text-decoration: none; padding: 4px; }

.page-content { padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-actions { display: flex; gap: 8px; }

/* ============================================================
   KPI Cards (Dashboard)
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
    background: white; border-radius: 12px; padding: 20px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); transition: transform 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-icon { font-size: 24px; width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-green .kpi-icon { background: #e8f5e9; }
.kpi-blue .kpi-icon { background: #e3f2fd; }
.kpi-orange .kpi-icon { background: #fff3e0; }
.kpi-purple .kpi-icon { background: #f3e5f5; }
.kpi-value { font-size: 22px; font-weight: 800; line-height: 1; }
.kpi-label { font-size: 13px; color: #888; margin-top: 2px; }

/* ============================================================
   Stats Grid (Safra Show)
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: white; border-radius: 12px; padding: 16px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-card-warning { border-left: 4px solid #e65100; }
.stat-card-info { border-left: 4px solid #1565c0; }
.stat-icon { font-size: 20px; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-label { font-size: 12px; color: #888; }

/* ============================================================
   Detail Grid (Show pages)
   ============================================================ */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-label { font-size: 12px; color: #888; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.detail-value { font-size: 15px; font-weight: 500; }

/* ============================================================
   Filters
   ============================================================ */
.filters { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-btn {
    padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 500;
    text-decoration: none; color: #666; background: white; border: 1px solid #e0e0e0;
    transition: all 0.2s;
}
.filter-btn:hover { border-color: #1b5e20; color: #1b5e20; text-decoration: none; }
.filter-btn.active { background: #1b5e20; color: white; border-color: #1b5e20; }

/* ============================================================
   Empty States
   ============================================================ */
.empty-state { text-align: center; padding: 60px 24px; color: #888; background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.empty-state h3 { margin: 12px 0 8px; color: #555; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }
.empty-state .btn { margin-top: 8px; }
.empty-state-sm { text-align: center; padding: 32px 16px; color: #888; }
.empty-icon { font-size: 48px; display: block; margin-bottom: 8px; }

/* ============================================================
   Market Cards
   ============================================================ */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.market-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.market-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.market-card-header h3 { font-size: 16px; font-weight: 600; }
.market-price { font-size: 20px; font-weight: 800; color: #1b5e20; }
.market-update { font-size: 12px; color: #888; }

/* ============================================================
   Property Cards
   ============================================================ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.property-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); transition: transform 0.2s; }
.property-card:hover { transform: translateY(-2px); }
.property-header { margin-bottom: 12px; }
.property-header h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.property-location { font-size: 13px; color: #888; }
.property-meta { display: flex; gap: 16px; font-size: 13px; color: #666; margin-top: 12px; }
.property-meta span { display: flex; align-items: center; gap: 4px; }

/* ============================================================
   Negotiation / Offer Cards
   ============================================================ */
.offer-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 12px; }
.offer-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.offer-buyer, .offer-producer { font-weight: 600; font-size: 15px; }
.offer-crop { font-size: 13px; color: #888; margin-top: 2px; }
.offer-details { display: flex; gap: 24px; font-size: 14px; color: #555; }
.offer-value { font-size: 18px; font-weight: 700; color: #1b5e20; }

/* ============================================================
   Chart Placeholder
   ============================================================ */
.chart-placeholder {
    height: 250px; background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    flex-direction: column;
}

/* ============================================================
   Success Page (Solicitação)
   ============================================================ */
.success-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f8faf8; }
.success-card { max-width: 480px; padding: 48px; background: white; border-radius: 16px; text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.success-card .icon { font-size: 64px; margin-bottom: 16px; }
.success-card h1 { font-size: 28px; color: #1b5e20; margin: 12px 0; }
.success-card p { color: #666; font-size: 16px; line-height: 1.6; }
.success-card .note { background: #e8f5e9; padding: 16px; border-radius: 8px; margin-top: 24px; font-size: 14px; color: #2e7d32; }

/* ============================================================
   Request Page (Solicitar Acesso)
   ============================================================ */
.request-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #e8f5e9 0%, #fff 50%, #f1f8e9 100%); padding: 40px 20px; }
.request-card { max-width: 560px; width: 100%; background: white; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.08); overflow: hidden; }
.request-header { background: linear-gradient(135deg, #1b5e20, #2e7d32); color: white; padding: 32px; text-align: center; }
.request-header h1 { font-size: 24px; margin: 8px 0 4px; }
.request-header p { opacity: 0.9; font-size: 14px; }
.request-body { padding: 32px; }
.radio-group { display: flex; gap: 16px; margin-top: 8px; margin-bottom: 20px; }
.radio-option { flex: 1; }
.radio-option input { display: none; }
.radio-option label {
    display: block; padding: 16px; border: 2px solid #e0e0e0; border-radius: 8px;
    text-align: center; cursor: pointer; transition: all 0.3s; font-size: 14px;
}
.radio-option input:checked + label { border-color: #1b5e20; background: #e8f5e9; color: #1b5e20; font-weight: 600; }
.radio-option label .icon { font-size: 32px; display: block; margin-bottom: 8px; }
.required { color: #d32f2f; }
.btn-request { width: 100%; padding: 14px; background: #1b5e20; color: white; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.3s; }
.btn-request:hover { background: #2e7d32; }
.back-link { text-align: center; margin-top: 24px; }
.back-link a { color: #1b5e20; text-decoration: none; font-size: 14px; }
.back-link a:hover { text-decoration: underline; }
.error-msg { background: #ffebee; color: #c62828; padding: 12px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

/* ============================================================
   404 Page
   ============================================================ */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f8faf8; }
.error-card { text-align: center; padding: 48px; }
.error-card h1 { font-size: 72px; font-weight: 800; color: #1b5e20; }
.error-card h2 { font-size: 24px; color: #333; margin: 12px 0; }
.error-card p { color: #888; margin-bottom: 24px; }

/* ============================================================
   Contract
   ============================================================ */
.contract-section { margin-bottom: 32px; }
.contract-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #1b5e20; }
.signature-box { border: 2px dashed #e0e0e0; border-radius: 12px; padding: 32px; text-align: center; margin-top: 12px; }
.signature-box.signed { border-color: #1b5e20; background: #f9f9f9; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .offer-details { flex-direction: column; gap: 8px; }
}
