/* ============================================
   AGRO - MVP Styles
   Clean, minimal design with emerald accents
   ============================================ */

/* CSS Variables for easy customization */
:root {
    --color-primary: #10b981;
    --color-primary-dark: #059669;
    --color-primary-light: #d1fae5;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --color-bg: #f9fafb;
    --color-bg-white: #ffffff;
    --color-success: #065f46;
    --color-success-bg: #f0fdf4;
    --color-error: #991b1b;
    --color-error-bg: #fef2f2;
    --color-warning: #92400e;
    --color-warning-bg: #fffbeb;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* ============================================
   TICKER - Price Ticker Bar
   ============================================ */
.ticker-wrap {
    width: 100%;
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    z-index: 1000;
}

.ticker {
    display: inline-block;
    white-space: nowrap;
    animation: ticker 35s linear infinite;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    padding: 0 32px;
    font-size: 14px;
    gap: 8px;
}

.ticker-name {
    color: var(--color-text-muted);
    font-weight: 500;
}

.ticker-price {
    color: var(--color-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.ticker-var {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.var-up {
    background: var(--color-primary-light);
    color: var(--color-success);
}

.var-down {
    background: var(--color-error-bg);
    color: var(--color-error);
}

@keyframes ticker {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-50%, 0, 0);
    }
}

/* ============================================
   HEADER - Navigation
   ============================================ */
header {
    margin-top: 46px;
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    padding: 16px 24px;
    position: sticky;
    top: 46px;
    z-index: 999;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.nav-links {
    display: flex;
    gap: 24px;
    list-style: none;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--color-primary);
}

/* Wallet Button */
.btn-wallet {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-wallet:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.btn-wallet.connected {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-primary-light);
}

/* ============================================
   HERO Section
   ============================================ */
.hero {
    background: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    padding: 64px 24px;
    text-align: center;
}

.hero-content {
    max-width: 600px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.hero p {
    font-size: 18px;
    color: var(--color-text-muted);
    margin-bottom: 32px;
}

.cta-button {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    padding: 14px 32px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.cta-button:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

/* ============================================
   LAYOUT - Container & Grid
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.section-subtitle {
    color: var(--color-text-muted);
    font-size: 16px;
    margin-bottom: 32px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
}

.card-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.card-subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

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

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg-white);
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-hint {
    font-size: 13px;
    color: var(--color-text-light);
    margin-top: 6px;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

/* ============================================
   RESULTS - Loan Calculator Results
   ============================================ */
.result-box {
    margin-top: 24px;
    padding: 20px;
    border-radius: 8px;
    display: none;
    border: 1px solid;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-success {
    background: var(--color-success-bg);
    border-color: var(--color-primary);
}

.result-error {
    background: var(--color-error-bg);
    border-color: #ef4444;
}

.result-header {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-success .result-header {
    color: var(--color-success);
}

.result-error .result-header {
    color: var(--color-error);
}

.result-body {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
}

.result-highlight {
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 18px;
}

.detail-box {
    background: var(--color-bg-white);
    border: 1px solid var(--color-primary-light);
    border-radius: 6px;
    padding: 16px;
    margin-top: 16px;
}

/* Disclaimer */
.disclaimer {
    margin-top: 20px;
    padding: 16px;
    background: var(--color-warning-bg);
    border: 1px solid #fcd34d;
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-warning);
    line-height: 1.5;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.disclaimer strong {
    color: #78350f;
    display: block;
    margin-bottom: 4px;
}

/* ============================================
   MARKETPLACE - Products Grid
   ============================================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.product-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.product-image {
    height: 140px;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    border-bottom: 1px solid var(--color-border-light);
}

.product-info {
    padding: 16px;
}

.product-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--color-text);
    margin-bottom: 4px;
}

.product-origin {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.product-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin-bottom: 8px;
}

.product-stock {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.product-stock.agotado {
    color: #ef4444;
    font-weight: 600;
}

/* New product animation */
.product-card.product-new {
    opacity: 0;
    transform: translateY(-10px);
}

.btn-buy {
    width: 100%;
    padding: 10px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-buy:hover {
    background: var(--color-primary-dark);
}

.btn-buy:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.btn-delete {
    width: 100%;
    padding: 8px;
    background: transparent;
    color: #ef4444;
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* ============================================
   PUBLISH PRODUCT FORM (Producers)
   ============================================ */
.publish-form {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.publish-form-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-success);
    margin-bottom: 16px;
}

.publish-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 16px;
    align-items: end;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0; /* Prevents overflow */
}

.form-field .form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-field-btn {
    align-self: end;
}

/* Larger inputs for publish form */
.publish-form .form-input,
.publish-form .form-select {
    padding: 12px 14px;
    font-size: 15px;
    min-height: 44px;
    width: 100%;
}

.publish-form .form-input::placeholder {
    color: #9ca3af;
}

.publish-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.publish-price-row .price-prefix {
    font-weight: 700;
    color: var(--color-text);
    font-size: 16px;
    flex-shrink: 0;
}

.publish-price-row .form-input {
    flex: 1;
    min-width: 60px;
}

.publish-price-row .form-select {
    flex: 1;
    min-width: 90px;
}

.publish-form .btn {
    width: auto;
    padding: 12px 24px;
    white-space: nowrap;
    min-height: 44px;
}

.publish-form-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ============================================
   DEMAND BANNER
   ============================================ */
.demand-section {
    margin-top: 40px;
}

.demand-banner {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
}

.demand-header {
    margin-bottom: 20px;
}

.demand-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Demand Form */
.demand-form {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.demand-form-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
}

.demand-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.demand-quantity-row {
    display: flex;
    gap: 8px;
}

.demand-quantity-row .form-input {
    width: 80px;
}

.demand-quantity-row .form-select {
    width: 100px;
}

.demand-form .btn {
    width: auto;
    padding: 10px 20px;
    white-space: nowrap;
}

.demand-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.demand-item {
    background: var(--color-success-bg);
    color: var(--color-text);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #a7f3d0;
    animation: pulse 2s infinite;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.demand-text {
    color: var(--color-success);
}

.btn-ofertar {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-ofertar:hover {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

/* New demand item animation */
.demand-item.demand-new {
    opacity: 0;
    transform: translateY(-10px);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* ============================================
   MODAL - Purchase Cycle
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--color-bg-white);
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
}

.cycle-container {
    margin: 24px 0;
}

.cycle-step {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
    padding: 12px;
    border-radius: 8px;
    transition: all 0.3s;
    opacity: 0.5;
}

.cycle-step.active {
    background: var(--color-success-bg);
    opacity: 1;
    border: 1px solid var(--color-primary);
}

.cycle-step.completed {
    opacity: 1;
    color: var(--color-primary-dark);
}

.cycle-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--color-border);
    transition: all 0.3s;
}

.cycle-step.active .cycle-icon {
    background: var(--color-primary);
    color: white;
    animation: spin 1s linear infinite;
}

.cycle-step.completed .cycle-icon {
    background: var(--color-primary);
    color: white;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.cycle-text {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    flex: 1;
    text-align: left;
}

.cycle-line {
    width: 2px;
    height: 20px;
    background: var(--color-border);
    margin-left: 15px;
}

.btn-close {
    margin-top: 24px;
    background: var(--color-border-light);
    color: #374151;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: none;
}

.btn-close.show {
    display: inline-block;
}

/* Offer Modal Styles */
.oferta-modal-content {
    max-width: 420px;
}

.oferta-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.oferta-modal-content h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.oferta-modal-content p {
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

.oferta-form {
    text-align: left;
}

.oferta-form .form-group {
    margin-bottom: 16px;
}

.oferta-precio-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.oferta-precio-row span {
    font-weight: 600;
    font-size: 18px;
}

.oferta-precio-row .form-input {
    flex: 1;
}

.oferta-total {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: #f0fdf4;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 16px;
}

.oferta-total #ofertaTotal {
    color: var(--color-primary);
    font-size: 18px;
}

.oferta-disclaimer {
    font-size: 12px;
    color: var(--color-text-muted);
    background: #fff7ed;
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #f97316;
    text-align: left;
    margin-bottom: 20px;
}

.oferta-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.oferta-buttons .btn {
    width: 100%;
}

/* ============================================
   WALLET MODAL
   ============================================ */
/* ============================================
   TOAST Notifications
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-text);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: none;
    z-index: 10000;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.show {
    display: block;
}

/* ============================================
   RESPONSIVE - Mobile First
   ============================================ */
@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .nav-links {
        gap: 12px;
    }

    .nav-links a {
        display: none;
    }

    .btn-wallet {
        padding: 8px 12px;
        font-size: 13px;
    }

    .hero h1 {
        font-size: 28px;
    }

    .hero p {
        font-size: 16px;
    }

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

    .demand-grid {
        flex-direction: column;
    }

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

    /* Publish Form - Stack in single column */
    .publish-form-title {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 20px;
        text-align: center;
        color: var(--color-success);
    }

    .publish-form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .publish-form .form-field {
        width: 100%;
    }

    .publish-form .form-label {
        display: block;
        font-size: 14px;
        font-weight: 500;
        color: #374151;
        margin-bottom: 8px;
    }

    .publish-form .form-input,
    .publish-form .form-select {
        width: 100%;
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 14px;
    }

    .publish-price-row {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .publish-price-row .price-prefix {
        font-size: 18px;
        font-weight: 600;
        color: var(--color-text);
        padding: 0 4px;
    }

    .publish-price-row .form-input {
        flex: 1;
        min-width: 100px;
    }

    .publish-price-row .form-select {
        flex: 1;
        min-width: 120px;
        max-width: 140px;
    }

    .publish-form .btn {
        width: 100%;
        padding: 14px 24px;
        min-height: 48px;
        font-size: 16px;
        margin-top: 8px;
    }

    /* Demand Form - Stack in single column */
    .demand-form-title {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 20px;
        color: var(--color-text);
    }

    .demand-form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .demand-form .form-field {
        width: 100%;
    }

    .demand-form .form-label {
        display: block;
        font-size: 14px;
        font-weight: 500;
        color: #374151;
        margin-bottom: 8px;
    }

    .demand-form .form-input,
    .demand-form .form-select {
        width: 100%;
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 14px;
    }

    .demand-quantity-row {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .demand-quantity-row .form-input {
        flex: 1;
        width: 100%;
    }

    .demand-quantity-row .form-select {
        flex: 1;
        min-width: 110px;
        max-width: 140px;
    }

    .demand-form .btn {
        width: 100%;
        padding: 14px 24px;
        min-height: 48px;
        font-size: 16px;
        margin-top: 8px;
    }

    /* Adjust form field labels */
    .form-field .form-label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    /* Better spacing for forms on mobile */
    .publish-form,
    .demand-form {
        padding: 16px;
    }

    /* Card padding adjustment */
    .card {
        padding: 16px;
    }

    /* Modal content adjustments */
    .modal-content {
        padding: 24px;
        margin: 16px;
    }

    /* Toast positioning for mobile */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .ticker-item {
        padding: 0 16px;
    }

    .container {
        padding: 24px 16px;
    }
}
