/* ============================================
   AgroInsight - Estilos Principais
   ============================================ */

:root {
    --primary-color: #22c55e;
    --primary-dark: #16a34a;
    --primary-light: #dcfce7;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --bg-color: #f9fafb;
    --text-color: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    width: 100%;
    overflow-x: hidden;
    position: relative;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* ============================================
   Layout Principal
   ============================================ */

.layout-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 3px;
}

.sidebar-subtitle {
    font-size: 11px;
    opacity: 0.9;
}

.sidebar-nav {
    flex: 1;
    padding: 11px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: white;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.2);
    border-left: 3px solid white;
}

.nav-icon {
    margin-right: 12px;
    font-size: 16px;
}

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    margin-bottom: 9px;
}

.user-name {
    font-weight: 600;
    margin-bottom: 3px;
    font-size: 13px;
}

.user-email {
    font-size: 11px;
    opacity: 0.8;
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 6px;
    text-align: center;
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 13px;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
    position: relative;
}

.content-header {
    background: white;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
}

.content-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.content-body {
    padding: 32px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ============================================
   Autenticação
   ============================================ */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.auth-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
}

.auth-form {
    margin-bottom: 24px;
}

.auth-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Cards e Componentes
   ============================================ */

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* Dashboard Stats */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    border-radius: 8px;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 2px;
    line-height: 1.2;
}

.stat-content p {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.3;
}

/* ============================================
   Formulários
   ============================================ */

.form {
    max-width: 800px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-color);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    max-width: 100%;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Botões
   ============================================ */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* ============================================
   Tabelas
   ============================================ */

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg-color);
}

.table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-color);
}

/* ============================================
   Alertas
   ============================================ */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ============================================
   Badges
   ============================================ */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-secondary {
    background: #e5e7eb;
    color: #374151;
}

/* ============================================
   Info Grid
   ============================================ */

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-item-full {
    grid-column: 1 / -1;
}

.info-item label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.info-item p {
    font-size: 16px;
    color: var(--text-color);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ============================================
   Utilitários
   ============================================ */

.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   Weather Components
   ============================================ */

.weather-container {
    max-width: 1200px;
}

.weather-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.weather-card {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.weather-card.weather-temp {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.weather-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.weather-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.weather-label {
    font-size: 14px;
    opacity: 0.8;
}

.weather-range {
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.9;
}

.weather-description {
    margin-top: 16px;
    padding: 12px;
    background: #f3f4f6;
    border-radius: 8px;
    text-align: center;
}

.forecast-list {
    display: grid;
    gap: 12px;
}

.forecast-item {
    display: grid;
    grid-template-columns: 100px 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

.forecast-date {
    display: flex;
    flex-direction: column;
}

.forecast-date strong {
    font-size: 18px;
}

.forecast-date span {
    font-size: 12px;
    color: var(--text-muted);
}

.forecast-weather {
    display: flex;
    align-items: center;
    gap: 8px;
}

.forecast-temp {
    font-weight: 600;
}

.forecast-precip {
    font-size: 14px;
}

.capitalize {
    text-transform: capitalize;
}

.alerts-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.alert-icon {
    font-size: 24px;
    margin-right: 12px;
}

.alert {
    display: flex;
    align-items: start;
    padding: 16px;
}

/* ============================================
   Soil Analysis Components
   ============================================ */

.soil-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.soil-param-card {
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.param-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.param-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
}

/* ============================================
   Action Cards
   ============================================ */

.actions-grid {
    margin-top: 24px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s;
}

.action-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.action-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.action-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.action-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Export Options
   ============================================ */

.export-options {
    display: flex;
    gap: 16px;
}

/* ============================================
   Filter Group
   ============================================ */

.filter-group {
    display: flex;
    gap: 12px;
}

.form-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}

/* ============================================
   Badge Colors
   ============================================ */

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ============================================
   Responsivo
   ============================================ */

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1003;
    position: relative;
}

.mobile-menu-btn span {
    width: 100%;
    height: 3px;
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s;
    display: block;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Modal Styles - Global */
.modal {
    display: none;
    position: fixed;
    z-index: 998;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 24px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
    margin-top: 60px;
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
    z-index: 1;
}

.modal-close:hover {
    color: #000;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    .mobile-menu-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 1003 !important;
        position: relative !important;
    }
    
    /* Force button to be visible even if hidden by other styles */
    button.mobile-menu-btn,
    .content-header .mobile-menu-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1001;
        width: 280px;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .content-body {
        padding: 12px 16px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .content-header {
        padding: 12px 16px;
        z-index: 1002;
        position: relative;
        background: white;
    }
    
    .content-header h2 {
        font-size: 16px;
    }
    
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .card-header {
        padding: 12px 16px;
    }
    
    .card-header h3 {
        font-size: 16px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-content h3 {
        font-size: 20px;
    }
    
    .stat-content p {
        font-size: 11px;
    }
    
    /* Modal adjustments for mobile */
    .modal {
        z-index: 998;
    }
    
    .modal-content {
        margin: 80px auto 20px;
        width: 95%;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .weather-grid {
        grid-template-columns: 1fr;
    }
    
    .forecast-item {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
    }
    
    .export-options {
        flex-direction: column;
    }
    
    /* Prevent horizontal scroll */
    .content-header {
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    .card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        width: 100%;
        max-width: 100%;
    }
    
    img, video, iframe {
        max-width: 100%;
        height: auto;
    }
    
    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Adjust form elements */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 10px 12px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    /* Adjust table */
    .table {
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 8px 12px;
    }
    
    /* Adjust dashboard grid */
    .dashboard-grid {
        gap: 12px;
    }
    
    /* Adjust stats grid */
    .stats-grid {
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    /* Adjust sidebar */
    .sidebar-header h1 {
        font-size: 18px;
    }
    
    .nav-item {
        font-size: 13px;
        padding: 8px 16px;
    }
    
    /* Adjust spacing */
    .form-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}
