/*
 * Mani Agro — Componentes Reutilizáveis
 */

/* ─── Botões ─────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: 1;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    min-height: 44px;
    white-space: nowrap;
    cursor: pointer;
    border: none;
    text-decoration: none;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-inverse);
    box-shadow: 0 4px 14px rgba(15,90,49,0.2);
    border: 1px solid rgba(0, 0, 0, 0.05);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    box-shadow: 0 6px 20px rgba(15,90,49,0.3);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0) scale(0.97);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.btn-secondary:active {
    transform: translateY(0) scale(0.97);
}

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

.btn-danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.btn-sm { padding: 8px 16px; font-size: var(--text-xs); min-height: 36px; }
.btn-lg { padding: 16px 32px; font-size: var(--text-base); min-height: 52px; border-radius: var(--radius-xl); }
.btn-full { width: 100%; }
.btn-icon { padding: 10px; min-height: 44px; min-width: 44px; border-radius: var(--radius-lg); }

/* ─── Inputs ─────────────────────────────── */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text);
    margin-bottom: var(--space-1);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: var(--text-base);
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    min-height: 48px;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.form-input.error { border-color: var(--danger); }

.form-select {
    width: 100%;
    padding: 12px 40px 12px 16px;
    font-size: var(--text-base);
    color: var(--text);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239CA3AF' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    appearance: none;
    min-height: 48px;
    transition: all var(--transition-fast);
}
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }

.form-helper { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }
.form-error  { font-size: var(--text-xs); color: var(--danger); margin-top: var(--space-1); }

/* ─── Cards ──────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-fast);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-body { padding: var(--space-4); }
.card-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}
.card-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-light);
    background: var(--surface-hover);
}

/* ─── Bottom Navigation ──────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-bottom-nav);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 0;
    min-width: 56px;
    min-height: 44px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
    background: none;
    border: none;
}
.bottom-nav__item svg {
    width: 22px;
    height: 22px;
    transition: all var(--transition-fast);
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
}
.bottom-nav__item span {
    font-size: 10px;
    font-weight: var(--font-medium);
    letter-spacing: 0.02em;
    transition: all var(--transition-fast);
}
.bottom-nav__item.active {
    color: var(--primary);
}
.bottom-nav__item.active svg {
    stroke-width: 2.2;
}
.bottom-nav__item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 var(--radius-full) var(--radius-full);
}

/* Badge de notificação no nav */
.bottom-nav__badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 10px));
    min-width: 16px;
    height: 16px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: var(--font-bold);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

/* ─── Modal / Overlay ────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 26, 18, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-overlay);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    width: 100%;
    max-width: var(--max-width);
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform var(--transition-spring);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -8px 32px rgba(15, 90, 49, 0.08);
}
.modal-overlay.active .modal { transform: translateY(0); }

.modal__handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    margin: var(--space-3) auto;
}
.modal__header {
    padding: var(--space-2) var(--space-4) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal__title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
}
.modal__close {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    transition: background var(--transition-fast);
    cursor: pointer; border: none; background: none;
}
.modal__close:hover { background: var(--surface-active); }
.modal__body { padding: 0 var(--space-4) var(--space-4); }
.modal__footer { padding: var(--space-4); border-top: 1px solid var(--border-light); display: flex; gap: var(--space-3); }

/* ─── Toast ──────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--space-3));
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    width: 100%;
    max-width: var(--max-width);
    padding: 0 var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    pointer-events: all;
    animation: fadeInUp var(--transition-base) both;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

.toast__message { flex: 1; font-size: var(--text-sm); font-weight: var(--font-medium); }
.toast__close {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full); color: var(--text-muted); cursor: pointer; border: none; background: none;
}

/* ─── Skeleton Loader ────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--surface-active) 25%, var(--border-light) 50%, var(--surface-active) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
.skeleton-text   { height: 14px; margin-bottom: var(--space-2); }
.skeleton-title  { height: 20px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-avatar { width: 44px; height: 44px; border-radius: var(--radius-full); }
.skeleton-card   { height: 120px; border-radius: var(--radius-xl); }
.skeleton-image  { height: 180px; border-radius: var(--radius-lg); }

/* ─── Badge ──────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-full);
    line-height: 1.4;
}
.badge-primary { background: var(--primary-100); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #065F46; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-danger  { background: var(--danger-light); color: #991B1B; }
.badge-info    { background: var(--info-light); color: #1E40AF; }
.badge-gray    { background: var(--surface-active); color: var(--text-secondary); }

/* ─── Avatar ─────────────────────────────── */
.avatar {
    width: 40px; height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--primary-100);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--text-xl); }

/* ─── Divider ────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-4) 0;
}

/* ─── Empty State ────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}
.empty-state svg { width: 64px; height: 64px; color: var(--text-muted); margin: 0 auto var(--space-4); opacity: 0.5; }
.empty-state h3  { margin-bottom: var(--space-2); color: var(--text); }
.empty-state p   { color: var(--text-muted); font-size: var(--text-sm); }

/* ─── List Item ──────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    transition: background var(--transition-fast);
    cursor: pointer;
    min-height: 60px;
    border-bottom: 1px solid var(--border-light);
    text-decoration: none;
    color: inherit;
}
.list-item:hover { background: var(--surface-hover); }
.list-item:active { background: var(--surface-active); }
.list-item__content { flex: 1; min-width: 0; }
.list-item__title { font-weight: var(--font-medium); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item__subtitle { font-size: var(--text-xs); color: var(--text-muted); margin-top: 1px; }
.list-item__action { color: var(--text-muted); flex-shrink: 0; }
.list-item__action svg { width: 18px; height: 18px; }

/* ─── Spinner ────────────────────────────── */
.spinner {
    width: 24px; height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

/* ─── Page Section ───────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0 var(--space-3);
}
.section-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
}
.section-action {
    font-size: var(--text-sm);
    color: var(--primary);
    font-weight: var(--font-medium);
}

/* ─── Tab bar ────────────────────────────── */
.tab-bar {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--surface-active);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-item {
    flex: 1;
    padding: 10px 16px;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    text-align: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
    border: none;
    background: none;
    min-height: 40px;
}
.tab-item.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

/* ─── Search bar ─────────────────────────── */
.search-bar {
    position: relative;
}
.search-bar__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    font-size: var(--text-sm);
    color: var(--text);
    transition: all var(--transition-fast);
}
.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* ─── Chip / Filter tag ──────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 6px 14px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.chip:hover { border-color: var(--primary-200); }
.chip.active {
    background: var(--primary-50);
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* ─── Chips scrollable container ─────────── */
.chips-scroll {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding: var(--space-2) var(--space-4);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }

/* ─── Stat card ──────────────────────────── */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    border: 1px solid var(--border-light);
}
.stat-card__label { font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-medium); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card__value { font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: var(--font-bold); color: var(--text); margin-top: var(--space-1); }
.stat-card__change { font-size: var(--text-xs); font-weight: var(--font-medium); margin-top: var(--space-1); display: flex; align-items: center; gap: var(--space-1); }
.stat-card__change.up   { color: var(--success); }
.stat-card__change.down { color: var(--danger); }
