/* ============= 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);
}

.btn-logout {
    background-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid var(--danger);
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.3);
}

.btn-back {
    background-color: rgba(139, 92, 246, 0.1);
    color: #ba80ff;
    border: 1px solid rgba(139, 92, 246, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-back:hover {
    background-color: rgba(139, 92, 246, 0.2);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    text-decoration: underline;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.3s ease;
}

.btn-link:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* ============= NAVBAR ============= */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 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;
}

.navbar-brand .logo-icon {
    height: 50px;
    width: auto;
    max-width: 280px;
    font-size: 18px;
    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-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.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-icon {
    width: 24px;
    height: 24px;
    color: white;
    flex-shrink: 0;
}

.username {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ============= 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-version-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-language-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.language-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 12px;
    cursor: pointer;
}

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

.language-link.active {
    color: var(--primary-light);
    font-weight: 600;
    background-color: rgba(139, 92, 246, 0.2);
}

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

/* ============= ALERT HISTORY MODAL ============= */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.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;
}

.loader {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 16px;
}

.no-alerts-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(30, 41, 59, 0.3) 100%);
    border: 1px dashed #10b981;
    border-radius: 8px;
    font-size: 16px;
}

.alerts-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
}

.alerts-table thead {
    background-color: rgba(139, 92, 246, 0.15);
    border-bottom: 2px solid var(--primary-color);
}

.alerts-table th {
    padding: 12px;
    text-align: left;
    color: var(--primary-light);
    font-weight: 600;
    font-size: 14px;
}

.alerts-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
}

.alerts-table tbody tr:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

.alerts-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============= 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-icon {
    font-size: 28px;
    flex-shrink: 0;
    animation: pulse 1s ease-in-out infinite;
}

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

.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.go-to-sensor {
    background-color: white;
    color: #ef4444;
}

.alert-notification-btn.go-to-sensor:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.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;
}

.alert-notification.critical-alert .alert-notification-icon {
    font-size: 32px;
}

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

    .navbar-menu {
        flex-wrap: wrap;
        gap: 10px;
    }

    .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;
    }
    
    .alerts-table {
        font-size: 12px;
    }
    
    .alerts-table th,
    .alerts-table td {
        padding: 8px;
    }

    .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;
    }
}
