/* ============================================================
 * IoT Management Platform — Main Stylesheet
 *
 * Design system matches the established FloodEye dark theme:
 *   Background:  #1a1a2e
 *   Panels:      #16213e
 *   Accent:      #4fc3f7 (cyan)
 *   Text:        #eee
 *   Muted:       #888
 * ============================================================ */


/* ---------- RESET & BASE ---------- */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    color: #eee;
    background: #1a1a2e;
    min-height: 100%;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: #4fc3f7;
    text-decoration: none;
}

a:hover {
    color: #81d4fa;
}


/* ---------- PARTICLES BACKGROUND ---------- */

#particles-js {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: #1a1a2e;
}


/* ---------- LOGIN PAGE ---------- */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: linear-gradient(165deg, rgba(28, 40, 68, 0.92) 0%, rgba(20, 28, 48, 0.95) 100%);
    border: 1px solid rgba(79, 195, 247, 0.1);
    border-radius: 16px;
    padding: 60px 60px 50px;
    width: 100%;
    max-width: 700px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    position: relative;
}

/* Animated glow border — slow pulsing cyan glow around the card */
.glow-border::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 17px;
    background: linear-gradient(
        var(--glow-angle, 0deg),
        rgba(79, 195, 247, 0.3),
        rgba(79, 195, 247, 0),
        rgba(79, 195, 247, 0),
        rgba(79, 195, 247, 0.15)
    );
    z-index: -1;
    animation: glowRotate 6s linear infinite, glowPulse 3s ease-in-out infinite;
}

@keyframes glowRotate {
    0%   { --glow-angle: 0deg; }
    100% { --glow-angle: 360deg; }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* Register the custom property so it can be animated */
@property --glow-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Logo container — gives the logo a clean white pill background */
.login-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.login-logo {
    display: block;
    width: 100%;
    max-height: none;
    object-fit: contain;
}

.login-title {
    text-align: center;
    font-size: 1.8em;
    font-weight: 600;
    color: #eee;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.login-subtitle {
    text-align: center;
    font-size: 1.1em;
    color: #667;
    margin-bottom: 36px;
}

/* Thin accent line under the header */
.login-divider {
    width: 40px;
    height: 2px;
    background: #4fc3f7;
    margin: 0 auto 28px;
    border-radius: 1px;
}


/* ---------- FORMS ---------- */

.form-group {
    margin-bottom: 28px;
}

.form-label {
    display: block;
    font-size: 1em;
    color: #888;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 16px 18px;
    background: #0c0f1a;
    color: #eee;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 1.05em;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: rgba(79, 195, 247, 0.5);
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1);
}

.form-input::placeholder {
    color: #555;
}


/* ---------- BUTTONS ---------- */

.btn {
    display: inline-block;
    padding: 16px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    text-align: center;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    color: #0c1020;
    width: 100%;
    box-shadow: 0 4px 15px rgba(79, 195, 247, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #67d0fa 0%, #4fc3f7 100%);
    box-shadow: 0 4px 20px rgba(79, 195, 247, 0.35);
}

.btn-secondary {
    background: #444;
    color: #eee;
}

.btn-secondary:hover {
    background: #555;
}

.btn-danger {
    background: #c62828;
    color: #fff;
}

.btn-danger:hover {
    background: #e53935;
}


/* ---------- MODAL OVERLAY ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: linear-gradient(145deg, #1e1e32 0%, #141428 100%);
    border-radius: 12px;
    padding: 30px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #eee;
    margin-bottom: 12px;
}

.modal-message {
    font-size: 0.95em;
    color: #aaa;
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions .btn {
    min-width: 100px;
}


/* ---------- STATUS BADGES ---------- */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-ok {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.badge-warn {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
}

.badge-fail {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}


/* ---------- ERROR MESSAGE (INLINE) ---------- */

.login-error {
    background: rgba(244, 67, 54, 0.15);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #f44336;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    margin-bottom: 20px;
    text-align: center;
    display: none;
}

.login-error.show {
    display: block;
}


/* ---------- FORGOT PASSWORD LINK ---------- */

.forgot-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    font-size: 1em;
    color: #888;
}

.forgot-link:hover {
    color: #4fc3f7;
}


/* ---------- DATA TABLES ---------- */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
}

.data-table thead {
    background: rgba(79, 195, 247, 0.06);
}

.data-table th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    color: #4fc3f7;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(79, 195, 247, 0.1);
    white-space: nowrap;
}

.data-table td {
    padding: 16px 20px;
    color: #ccc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(79, 195, 247, 0.03);
}

.data-table .actions-cell {
    white-space: nowrap;
}

/* Small buttons used inside tables */
.table-btn {
    padding: 8px 16px;
    font-size: 0.85em;
    display: inline-block;
    width: auto;
    margin: 2px;
}


/* ---------- PASSWORD TOGGLE ---------- */

.password-wrap {
    position: relative;
}

.password-wrap .form-input {
    padding-right: 52px;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.password-toggle:hover {
    color: #4fc3f7;
}

.password-toggle svg {
    width: 22px;
    height: 22px;
}


/* ---------- CHECKBOX (REMEMBER ME) ---------- */

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.checkbox-wrap input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    background: #0c0f1a;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s;
}

/* Checkmark when checked */
.checkbox-wrap input[type="checkbox"]:checked + .checkbox-custom {
    background: #4fc3f7;
    border-color: #4fc3f7;
}

.checkbox-wrap input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    width: 6px;
    height: 11px;
    border: solid #0c1020;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.checkbox-label {
    font-size: 0.95em;
    color: #888;
}


/* ---------- COOKIE BANNER ---------- */

.cookie-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(165deg, #1c2844 0%, #141c30 100%);
    border-top: 1px solid rgba(79, 195, 247, 0.12);
    padding: 20px 32px;
    z-index: 3000;
    align-items: center;
    justify-content: center;
    gap: 24px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.cookie-banner.show {
    display: flex;
}

.cookie-text {
    font-size: 1em;
    color: #ccc;
    max-width: 600px;
}

.cookie-btn {
    width: auto;
    padding: 12px 28px;
    font-size: 0.95em;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .cookie-banner {
        flex-direction: column;
        padding: 20px;
        gap: 16px;
        text-align: center;
    }

    .cookie-btn {
        width: 100%;
    }
}


/* ---------- LOADING SPINNER ---------- */

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(26, 26, 46, 0.3);
    border-top-color: #1a1a2e;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ============================================================
 * SIDEBAR LAYOUT
 * ============================================================ */

/* ---------- SIDEBAR CONTAINER ---------- */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #141c30 0%, #0f1525 100%);
    border-right: 1px solid rgba(79, 195, 247, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
}

/* Main content shifts right to make room for sidebar */
body.has-sidebar .main-content {
    margin-left: 260px;
    min-height: 100vh;
    padding: 32px 40px;
}


/* ---------- SIDEBAR BRAND (TOP) ---------- */

.sidebar-brand {
    padding: 28px 24px 24px;
    border-bottom: 1px solid rgba(79, 195, 247, 0.06);
    text-align: center;
}

.sidebar-logo {
    max-width: 160px;
    max-height: 55px;
    object-fit: contain;
    margin-bottom: 12px;
    background: #fff;
    padding: 8px 14px;
    border-radius: 8px;
}

.sidebar-customer-name {
    font-size: 1.15em;
    font-weight: 600;
    color: #eee;
    margin-bottom: 2px;
}

.sidebar-platform-label {
    font-size: 0.8em;
    color: #888;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}


/* ---------- SIDEBAR NAVIGATION ---------- */

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    color: #888;
    font-size: 0.95em;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 4px;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(79, 195, 247, 0.06);
    color: #ccc;
}

.sidebar-link.active {
    background: rgba(79, 195, 247, 0.1);
    color: #4fc3f7;
}

.sidebar-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-icon svg {
    width: 20px;
    height: 20px;
}

.sidebar-label {
    white-space: nowrap;
}

/* Section divider label in sidebar (e.g. "Platform Admin") */
.sidebar-section-label {
    font-size: 0.7em;
    font-weight: 600;
    color: #4fc3f7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 20px 16px 8px;
    border-top: 1px solid rgba(79, 195, 247, 0.06);
    margin-top: 8px;
}


/* ---------- SIDEBAR BOTTOM ---------- */

.sidebar-bottom {
    padding: 12px 12px 20px;
    border-top: 1px solid rgba(79, 195, 247, 0.06);
}

.sidebar-user {
    padding: 12px 16px;
    margin-bottom: 4px;
}

.sidebar-user-name {
    font-size: 0.9em;
    font-weight: 600;
    color: #ccc;
}

.sidebar-user-role {
    font-size: 0.75em;
    color: #4fc3f7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.sidebar-signout {
    color: #666;
}

.sidebar-signout:hover {
    color: #f44336;
    background: rgba(244, 67, 54, 0.06);
}

.sidebar-footer {
    padding: 16px 16px 0;
    text-align: center;
}

.sidebar-footer-iot {
    font-size: 0.85em;
    font-weight: 600;
    color: #4fc3f7;
}

.sidebar-footer-mgmt {
    font-size: 0.85em;
    font-weight: 600;
    color: #999;
}

.sidebar-footer-version {
    font-size: 0.8em;
    color: #777;
    margin-left: 8px;
}


/* ---------- PAGE CONTENT PANELS ---------- */

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.8em;
    font-weight: 600;
    color: #eee;
    margin-bottom: 6px;
}

.page-subtitle {
    font-size: 1em;
    color: #999;
}

.content-card {
    background: linear-gradient(165deg, #1c2844 0%, #141c30 100%);
    border: 1px solid rgba(79, 195, 247, 0.08);
    border-radius: 14px;
    padding: 32px;
    margin-bottom: 24px;
}


/* ---------- MOBILE HEADER ---------- */

.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
}


/* ---------- RESPONSIVE — MOBILE ---------- */

@media (max-width: 768px) {

    /* Hide sidebar off-screen on mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    /* Show sidebar when open class is added */
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    /* Main content takes full width on mobile */
    body.has-sidebar .main-content {
        margin-left: 0;
        padding: 80px 20px 20px;
    }

    /* Mobile top bar with hamburger */
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 16px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: linear-gradient(180deg, #141c30 0%, #0f1525 100%);
        border-bottom: 1px solid rgba(79, 195, 247, 0.08);
        padding: 0 20px;
        z-index: 999;
    }

    .mobile-title {
        font-size: 1.1em;
        font-weight: 600;
        color: #eee;
    }

    /* Hamburger icon — three lines */
    .hamburger {
        background: none;
        border: none;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        gap: 5px;
        padding: 4px;
    }

    .hamburger span {
        display: block;
        width: 24px;
        height: 2px;
        background: #eee;
        border-radius: 1px;
        transition: transform 0.3s, opacity 0.3s;
    }

    /* Hamburger transforms to X when sidebar is open */
    .hamburger.active span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Dark overlay behind sidebar on mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* ---------- RESPONSIVE — LOGIN PAGE (MOBILE) ---------- */

@media (max-width: 480px) {
    .login-card {
        padding: 36px 28px 32px;
    }

    .login-logo {
        width: 100%;
    }

    .modal-box {
        padding: 24px 20px;
    }
}
