/* ============= SHARED COMPONENTS ============= */

/* Base styles and variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --alert-low: #10b981;
    --alert-mid: #f59e0b;
    --alert-high: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
        'Helvetica Neue', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============= BUTTONS ============= */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-primary);
}

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

/* ============= NAVBAR ============= */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.navbar-brand .logo-icon {
    height: 36px;
    width: auto;
    max-width: 220px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    object-fit: contain;
}

.navbar-brand h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-light);
    margin: 0;
    letter-spacing: 0.5px;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.navbar-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.navbar-link:hover {
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--text-primary);
}

.navbar-link.active {
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--primary-light);
}

.navbar-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-radius: 8px;
    background-color: rgba(139, 92, 246, 0.15);
    border: 1.5px solid var(--primary-color);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

/* ============= HEADER LANGUAGE SWITCHER ============= */
.header-language-dropdown {
    position: relative;
    display: inline-block;
}

.header-language-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    background-color: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.35);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.header-language-button-label {
    font-size: 12px;
    font-weight: 400;
    color: #cbd5e1;
    white-space: nowrap;
}

.header-language-button:hover {
    background-color: rgba(139, 92, 246, 0.22);
    border-color: #ba80ff;
}

.header-language-button.active {
    background-color: rgba(139, 92, 246, 0.22);
    border-color: #ba80ff;
}

.header-language-button.active .dropdown-arrow {
    transform: rotate(180deg);
}

.header-language-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.header-language-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #0f172a;
    min-width: 150px;
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    margin-top: 8px;
    z-index: 1000;
    overflow: hidden;
}

.header-language-dropdown-content.show {
    display: block;
}

/* ============= FOOTER ============= */
.app-footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    background-color: var(--bg-card);
    position: relative;
    bottom: 0;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.app-footer .version {
    font-weight: 600;
    color: var(--primary-light);
    margin: 0 8px;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 15px;
}

.footer-copyright {
    font-size: 11px;
    color: var(--text-secondary);
}

.modal-content {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(30, 41, 59, 0.8) 100%);
    border: 1px solid var(--primary-color);
    margin: 5% auto;
    padding: 0;
    max-width: 900px;
    width: 90%;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(139, 92, 246, 0.3);
    animation: slideDown 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--primary-light);
    font-size: 24px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--primary-color);
}

.modal-body {
    padding: 24px;
    max-height: 600px;
    overflow-y: auto;
}

/* ============= ALERT NOTIFICATIONS ============= */
#alert-notifications-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10000;
    pointer-events: none;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
}

#alert-notifications-container .alert-notification {
    pointer-events: auto;
}

.alert-notification {
    position: relative;
    bottom: auto;
    right: auto;
    max-width: 240px;
    width: auto;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
    border: none;
    border-radius: 12px;
    padding: 14px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 60px rgba(239, 68, 68, 0.4);
    animation: slideInRight 0.4s ease-out;
    transition: transform 0.2s ease;
}

.alert-notification:hover {
    box-shadow: 0 25px 70px rgba(239, 68, 68, 0.5);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-notification-content {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.alert-notification-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alert-notification-title {
    font-size: 16px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.3px;
}

.alert-notification-message {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
}

.alert-notification-message strong {
    color: white;
    font-weight: 700;
}

.alert-notification-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.alert-notification-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.alert-notification-btn.close-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 10px;
    min-width: auto;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-notification-btn.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.alert-notification.critical-alert {
    background: linear-gradient(135deg, rgba(127, 29, 29, 0.98) 0%, rgba(153, 27, 27, 0.98) 100%);
    box-shadow: 0 20px 60px rgba(127, 29, 29, 0.6);
    animation: slideInRight 0.3s ease-out;
}

/* ============= SENSOR CARD (shared base) =============
   Canonical look for the .sensor-card component: dashboard.css and
   reports.css each build on this with their own layout/padding, instead
   of redeclaring the gradient/border/hover recipe. */
.sensor-card {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(30, 41, 59, 0.6) 100%);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sensor-card:hover:not(.sensor-disconnected) {
    transform: translateY(-4px);
    border-color: var(--primary-light);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.2);
}

.sensor-alert-pulse {
    animation: alertPulse 2s ease-in-out infinite;
    border-color: #ef4444;
}

@keyframes alertPulse {
    0%, 100% {
        border-color: #ef4444;
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.3);
    }
}

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .navbar-links {
        flex-wrap: wrap;
    }

    .navbar-menu {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: flex-end;
    }

    .modal-content {
        margin: 20% auto;
        width: 95%;
    }
    
    .modal-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .modal-close {
        align-self: flex-end;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 70vh;
    }
    
    .alert-notification {
        width: 85%;
    }
    
    .alert-notification-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .alert-notification-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .alert-notification-btn {
        width: 100%;
    }
    
    .alert-notification-btn.close-btn {
        width: auto;
    }
}
