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

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8fafb;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e5e5;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    height: 40px;
    width: auto;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #262d2d;
    margin: 0;
}

.nav-menu {
    display: flex;
    gap: 2rem;
}

.nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-menu a:hover {
    color: #7db63b;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #7db63b, #5a8a3a);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(125, 182, 59, 0.3);
}

.btn-secondary {
    background: rgba(125, 182, 59, 0.1);
    color: #262d2d;
    border: 2px solid #7db63b;
}

.btn-secondary:hover {
    background: #7db63b;
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-voice {
    background: #7db63b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.btn-voice:hover {
    background: #5a8a3a;
    transform: scale(1.1);
}

/* Dashboard Layout */
.dashboard {
    padding-top: 100px;
    min-height: 100vh;
}

/* Status Overview */
.status-overview {
    padding: 2rem 0;
    background: white;
    margin-bottom: 2rem;
}

.status-overview h2 {
    color: #262d2d;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.status-card {
    background: white;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.status-card:hover {
    border-color: #7db63b;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.status-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7db63b, #5a8a3a);
    border-radius: 12px;
}

.status-content h3 {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.status-value {
    font-size: 2rem;
    font-weight: 700;
    color: #262d2d;
    margin-bottom: 0.3rem;
}

.status-change {
    font-size: 0.8rem;
    font-weight: 500;
}

.status-change.positive {
    color: #7db63b;
}

.status-change.negative {
    color: #e74c3c;
}

.status-change.neutral {
    color: #666;
}

/* Real-time Data */
.real-time-data {
    padding: 2rem 0;
}

.real-time-data h2 {
    color: #262d2d;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.canteiros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.canteiro-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.canteiro-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.canteiro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.canteiro-header h3 {
    font-size: 1.3rem;
    color: #262d2d;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.healthy {
    background: rgba(125, 182, 59, 0.1);
    color: #5a8a3a;
}

.status-badge.warning {
    background: rgba(255, 193, 7, 0.1);
    color: #f57c00;
}

.status-badge.critical {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* Sensor Readings */
.sensor-readings {
    margin-bottom: 2rem;
}

.sensor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.sensor-label {
    font-weight: 500;
    color: #666;
    min-width: 120px;
}

.sensor-value-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sensor-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: #262d2d;
    min-width: 60px;
    text-align: right;
}

.sensor-bar {
    flex: 1;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    max-width: 150px;
}

.sensor-fill {
    height: 100%;
    background: linear-gradient(90deg, #7db63b, #5a8a3a);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.sensor-fill.warning {
    background: linear-gradient(90deg, #ffc107, #f57c00);
}

.sensor-fill.critical {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

/* Actions */
.canteiro-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.canteiro-actions .btn {
    flex: 1;
}

/* AI Response */
.ai-response {
    background: #f9fcf6;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #7db63b;
    font-style: italic;
    color: #5a8a3a;
    display: none;
}

.ai-response.show {
    display: block;
    animation: slideDown 0.3s ease;
}

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


/* Alerts Section */
.alerts-section {
    padding: 3rem 0;
    margin-top: 2rem;
}

.alerts-section h2 {
    color: #262d2d;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid;
}

.alert.alert-critical {
    border-left-color: #e74c3c;
    background: rgba(231, 76, 60, 0.02);
}

.alert.alert-warning {
    border-left-color: #f57c00;
    background: rgba(255, 193, 7, 0.02);
}

.alert.alert-info {
    border-left-color: #3498db;
    background: rgba(52, 152, 219, 0.02);
}

.alert-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-content {
    flex: 1;
}

.alert-content h4 {
    color: #262d2d;
    margin-bottom: 0.5rem;
}

.alert-content p {
    color: #666;
    margin-bottom: 0.5rem;
}

.alert-content small {
    color: #999;
    font-size: 0.8rem;
}

.alert-actions {
    display: flex;
    gap: 0.5rem;
}

/* AI Chat Modal */
.ai-chat-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.ai-chat-overlay.show {
    display: flex;
}

.ai-chat-modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.ai-chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-header h3 {
    color: #262d2d;
    margin: 0;
}

.close-chat {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
}

.ai-chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 400px;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 12px;
    max-width: 80%;
}

.chat-message.ai-message {
    background: #f9fcf6;
    border: 1px solid #7db63b;
    margin-right: auto;
}

.chat-message.user-message {
    background: #7db63b;
    color: white;
    margin-left: auto;
}

.ai-chat-input {
    padding: 1.5rem;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.ai-chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 1rem;
}

.ai-chat-input input:focus {
    outline: none;
    border-color: #7db63b;
}

/* Responsive Design */
@media (max-width: 768px) {
    .canteiros-grid {
        grid-template-columns: 1fr;
    }
    
    
    .status-cards {
        grid-template-columns: 1fr;
    }
    
    .nav-menu {
        display: none;
    }
    
    .canteiro-actions {
        flex-direction: column;
    }
    
    .alert {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .alert-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 1rem;
    }
    
    .sensor-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .sensor-value-container {
        width: 100%;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #7db63b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pulse Animation for Real-time Updates */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* AI Consultant Section */
.ai-consultant-section {
    padding: 3rem 0;
    background: linear-gradient(135deg, #f9fcf6 0%, #eef7e3 100%);
    margin-top: 2rem;
}

.ai-consultant-section h2 {
    color: #262d2d;
    margin-bottom: 2rem;
    font-size: 2rem;
    text-align: center;
}

.ai-consultant-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    margin: 0 auto;
}

.consultant-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.consultant-info h3 {
    color: #262d2d;
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
}

.consultant-info p {
    color: #666;
    margin-bottom: 1rem;
}

.data-context {
    background: rgba(125, 182, 59, 0.1);
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #5a8a3a;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #5a8a3a;
}

.status-dot {
    width: 12px;
    height: 12px;
    background: #7db63b;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-container {
    margin-bottom: 2rem;
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.chat-message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.chat-message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chat-message.ai-message .message-avatar {
    background: linear-gradient(135deg, #7db63b, #5a8a3a);
}

.chat-message.user-message .message-avatar {
    background: #262d2d;
    color: white;
}

.message-content {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 80%;
    position: relative;
}

.chat-message.user-message .message-content {
    background: #7db63b;
    color: white;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
}

.quick-questions {
    margin-bottom: 1.5rem;
}

.quick-questions h4 {
    color: #262d2d;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.quick-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.8rem;
}

.btn-quick {
    background: rgba(125, 182, 59, 0.1);
    border: 2px solid #7db63b;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: #5a8a3a;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-align: left;
}

.btn-quick:hover {
    background: #7db63b;
    color: white;
    transform: translateY(-2px);
}

.chat-input-area {
    background: #f8fafb;
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid #e5e5e5;
}

.input-group {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.8rem;
}

.input-group input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #7db63b;
}

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #666;
}

.char-count {
    color: #999;
}

.context-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.context-toggle input[type="checkbox"] {
    accent-color: #7db63b;
}

.conversation-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    padding-top: 1.5rem;
    border-top: 2px solid #f0f0f0;
}

/* API Settings Modal */
.api-settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.api-settings-modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #262d2d;
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-body {
    padding: 1.5rem;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #262d2d;
}

.setting-group select,
.setting-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 1rem;
}

.setting-group input[type="range"] {
    width: calc(100% - 60px);
    margin-right: 10px;
}

#temp-value {
    font-weight: bold;
    color: #7db63b;
    min-width: 40px;
    display: inline-block;
}

.api-test {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

#api-test-result {
    font-size: 0.9rem;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
}

#api-test-result.success {
    background: rgba(125, 182, 59, 0.1);
    color: #5a8a3a;
}

#api-test-result.error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* Loading states */
.message-loading {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #7db63b;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Error states */
.error-message {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .consultant-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .quick-buttons {
        grid-template-columns: 1fr;
    }
    
    .conversation-actions {
        flex-direction: column;
    }
    
    .input-group {
        flex-wrap: wrap;
    }
    
    .input-info {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}