/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    margin-bottom: 0.5rem;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    gap: 2rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.user-info small {
    opacity: 0.9;
    font-size: 0.8rem;
}

.notification-bell {
    position: relative;
}

.bell-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    position: relative;
    padding: 0;
    transition: opacity 0.3s;
}

.bell-button:hover {
    opacity: 0.8;
}

.sound-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.3s;
    margin-left: 0.5rem;
}

.sound-toggle:hover {
    opacity: 0.8;
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

.notification-dropdown {
    position: absolute;
    top: 40px;
    left: -300px;
    width: 350px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #ddd;
}

.notification-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
    border-radius: 8px 8px 0 0;
}

.notification-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

.clear-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
}

.notifications-list {
    padding: 0;
}

.notification-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.notification-item:hover {
    background-color: #f9f9f9;
}

.notification-item.notification-alert {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
}

.notification-item.notification-warning {
    border-left: 4px solid #ffc107;
    background-color: #fffbf0;
}

.notification-item.notification-error {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
}

.notification-item.notification-info {
    border-left: 4px solid #17a2b8;
    background-color: #f0f8fb;
}

.notification-content {
    flex: 1;
}

.notification-content h4 {
    margin: 0 0 5px 0;
    font-size: 0.95rem;
    color: #333;
}

.notification-content p {
    margin: 0 0 5px 0;
    font-size: 0.85rem;
    color: #666;
}

.notification-content small {
    color: #999;
    font-size: 0.8rem;
}

.mark-read-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.mark-read-btn:hover {
    background-color: #764ba2;
}

.no-notifications {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}


.btn-secondary {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: #45a049;
}

main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card h2 {
    margin-bottom: 1rem;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

/* Overview Card */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
}

/* Device Status */
.devices-grid {
    display: grid;
    gap: 1rem;
}

.device-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 1rem;
    background: #fafafa;
    transition: box-shadow 0.3s;
}

.device-card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.device-name {
    font-weight: bold;
    color: #333;
}

.device-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-active {
    background-color: #4CAF50;
    color: white;
}

.status-inactive {
    background-color: #f44336;
    color: white;
}

.device-mac {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.device-crop {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
}

.sensor-item {
    text-align: center;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    border: 1px solid #eee;
}

.sensor-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.sensor-value {
    font-weight: bold;
    color: #333;
}

.device-actions {
    margin-top: 1rem;
    text-align: center;
}

.btn-secondary {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin: 0 0.25rem;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background-color: #1976D2;
}

/* Alerts */
.alerts-list {
    max-height: 300px;
    overflow-y: auto;
}

.alert-item {
    padding: 0.75rem;
    border-left: 4px solid;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.alert-warning {
    border-left-color: #ff9800;
}

.alert-error {
    border-left-color: #f44336;
}

.alert-info {
    border-left-color: #2196F3;
}

.alert-title {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.9rem;
    color: #666;
}

.alert-timestamp {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.25rem;
}

/* Manual Control */
.control-form {
    display: grid;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #333;
}

.form-group select,
.form-group input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .header-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
}