/* Mobile-First Base Styles (applied to all screen sizes unless overridden) */
body {
    font-family: "Roboto", sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f8f8;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh; /* Full viewport height */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

h1 {
    color: #007bff;
    text-align: center;
    margin-bottom: 20px;
    margin-top: 20px; /* Add top margin for login page */
}

.error-message {
    color: red;
    margin-top: 10px;
    text-align: center; /* Center error messages */
    min-height: 1.2em; /* Reserve space for error messages */
}

.status-message {
    margin-top: 10px;
    color: green;
    text-align: center; /* Center status messages */
    min-height: 1.2em; /* Reserve space for status messages */
}

/* --- Login Page (index.html) --- */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    width: 100%; /* Full width on mobile */
    box-sizing: border-box; /* Include padding in width calculation */
}

.form-container {
    background-color: #fff;
    padding: 25px; /* Slightly reduced padding for mobile */
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); /* Reduced shadow for mobile */
    display: flex;
    flex-direction: column;
    gap: 15px; /* Reduced gap for mobile */
    width: 95%; /* Take up most of the container width */
    max-width: 400px; /* Max width to prevent excessive width on larger mobiles */
    box-sizing: border-box;
}

.form-container input {
    padding: 10px; /* Reduced padding for mobile input */
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.form-container button {
    padding: 10px 15px; /* Reduced button padding for mobile */
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.form-container button:hover {
    background-color: #0056b3;
}

/* --- App Page (app.html) --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    width: 100%; /* Full width on mobile */
    box-sizing: border-box;
    overflow: hidden; /* Prevent bottom nav scrollbar */
}

/* --- THE DEFINITIVE FIX --- */
/* The old, single .content-area rule has been DELETED. */
/* Below are two new, separate rules that will not conflict. */

/* NEW RULE 1: For the SOS button page ONLY */
/* This rule uses 'grid' to robustly center the SOS button. */
.app-page .content-area {
    flex-grow: 1; /* Allow it to fill the vertical space */
    display: grid;
    place-items: center; /* This is a modern shorthand for vertical and horizontal centering */
    padding: 20px;
    box-sizing: border-box;
}

/* NEW RULE 2: For the Dashboard/Alerts page ONLY */
/* This rule uses 'flexbox' to create a top-aligned, scrollable list. */
.dashboard-page .content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Aligns content to the top */
    padding: 20px;
    text-align: center;
    box-sizing: border-box;
    overflow-y: auto; /* Enables scrolling */
    padding-bottom: 100px; /* Prevents nav bar from hiding the last item */
}

#panicButton {
    background-color: red;
    color: white;
    border: none;
    /* Increased button size by ~1.5x for mobile */
    width: 150px;
    height: 150px;
    border-radius: 50%;
    /* Increased font size to match */
    font-size: 2.4em;
    font-weight: bold; /* Make text bold */
    cursor: pointer;
    margin-bottom: 20px;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.7); /* Slightly reduced glow */
    transition:
        background-color 0.2s ease,
        box-shadow 0.2s ease;
    display: flex; /* Use flexbox to center text */
    align-items: center; /* Center text vertically */
    justify-content: center; /* Center text horizontally */
    line-height: 1; /* Ensure text is centered properly */
}

#panicButton:active {
    /* Style for when button is clicked */
    background-color: darkred;
    box-shadow: 0 0 15px rgba(180, 0, 0, 0.9); /* Darker glow on active */
}

#messageInstruction {
    margin-bottom: 10px;
    font-weight: bold;
}

#messageContainer {
    display: none; /* Keep hidden initially */
    flex-direction: column;
    gap: 8px; /* Reduced gap for mobile buttons */
    margin-top: 15px; /* Reduced margin */
    width: 90%; /* Message buttons width */
    max-width: 350px; /* Max width for message buttons */
    box-sizing: border-box;
}

.messageButton {
    padding: 10px 18px; /* Reduced button padding */
    border: 1px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    background-color: #fff;
    transition: background-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Reduced shadow */
    font-size: 0.95em; /* Slightly smaller font */
}

.messageButton:hover {
    background-color: #f0f0f0;
}

/* --- Bottom Navigation Bar --- */
.bottom-nav {
    background-color: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 0; /* Reduced padding */
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.03); /* Even lighter shadow */
    width: 100%; /* Full width for bottom nav */
    box-sizing: border-box;
}

.nav-button {
    background: none;
    border: none;
    padding: 8px 12px; /* Reduced button padding */
    cursor: pointer;
    font-size: 0.9em; /* Smaller nav button font */
    color: #555;
    transition: color 0.2s ease;
}

.nav-button:hover,
.nav-button.active {
    color: #007bff;
}

.login-logo {
    display: block;
    max-width: 120px; /* Adjust size as needed for apple-touch-icon */
    height: auto;
    margin-bottom: 20px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Media Queries for Larger Screens (Tablets/Desktops) --- */
@media (min-width: 768px) {
    /* Target tablets and larger */

    .login-logo {
        max-width: 160px; /* Slightly larger on tablets/desktops if desired */
        margin-bottom: 30px;
    }

    .login-container {
        max-width: 500px; /* Wider login container on larger screens */
    }
    .form-container {
        padding: 40px; /* More padding on larger screens */
        gap: 25px; /* Larger gap on larger screens */
        max-width: 450px;
    }
    .form-container input,
    .form-container button {
        padding: 14px; /* Larger input and button padding */
        font-size: 1.1em; /* Slightly larger font size */
    }

    .app-container {
        max-width: 800px; /* Wider app container on larger screens */
        margin: 0 auto; /* Center app container on larger screens */
    }
    #panicButton {
        /* Increased button size for desktop */
        width: 210px;
        height: 210px;
        /* Increased font size for desktop */
        font-size: 3em;
        margin-bottom: 30px; /* Increased margin */
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.6); /* Stronger glow on larger screens */
    }
    #messageContainer {
        gap: 12px; /* Larger gap for message buttons */
        margin-top: 30px; /* Increased margin */
        max-width: 400px; /* Wider message buttons area */
    }
    .messageButton {
        padding: 12px 22px; /* Larger message button padding */
        font-size: 1em; /* Slightly larger font */
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* Slightly stronger shadow */
    }
    .bottom-nav {
        padding: 15px 0; /* More padding for bottom nav on larger screens */
    }
    .nav-button {
        padding: 10px 15px; /* Larger nav button padding */
        font-size: 1em; /* Slightly larger nav button font */
    }
}

/* Dashboard Common Styles */
.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    width: 100%;
    max-width: 960px; /* Adjust max width as needed for dashboards */
    margin: 0 auto; /* Center the dashboard */
    box-sizing: border-box;
    padding: 20px;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 20px;
}

.dashboard-content {
    flex-grow: 1;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
    overflow-y: auto; /* Enable vertical scroll if content overflows */
}

.dashboard-footer {
    margin-top: 20px;
}

.dashboard-nav {
    background-color: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 0;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

/* Security Company Dashboard Specific Styles */
#panicAlerts ul {
    list-style: none;
    padding: 0;
}

.panic-alert-item {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.panic-alert-item h3 {
    color: red; /* Highlight emergency title */
    margin-top: 0;
    margin-bottom: 10px;
}

.panic-alert-item p {
    margin: 5px 0;
}

.panic-alert-item strong {
    font-weight: bold;
}

/* Area Manager Dashboard Specific Styles (can add more later) */

/* Responsive Adjustments (can refine further) */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
    }
    .dashboard-content {
        padding: 15px;
    }

    .profile-container {
        width: 100%;
        max-width: 500px; /* Constrain width on larger screens for readability */
        margin: 0 auto;
        padding: 20px 10px; /* Add padding for spacing */
        text-align: center;
        animation: fadeIn 0.5s ease-in-out; /* Add a subtle fade-in effect */
    }

    .profile-container h2 {
        color: #333;
        font-size: 1.8rem;
        font-weight: 600;
        margin-bottom: 25px;
    }

    .profile-info-card {
        background-color: #ffffff;
        border-radius: 12px; /* Softer, rounded corners */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); /* A subtle shadow for depth */
        padding: 15px 25px;
        text-align: left; /* Align text inside the card to the left */
    }

    .info-item {
        display: flex;
        flex-direction: column; /* Stack the label on top of the value */
        padding: 15px 0;
        border-bottom: 1px solid #f0f0f0; /* Light separator line */
    }

    .info-item:last-child {
        border-bottom: none; /* Remove the line from the very last item */
    }

    .info-label {
        font-size: 0.8rem;
        color: #6c757d; /* A muted, professional grey for the label */
        margin-bottom: 5px;
        text-transform: uppercase; /* Gives a clean, formal look */
        letter-spacing: 0.5px;
        font-weight: 600;
    }

    .info-value {
        font-size: 1.1rem;
        color: #212529; /* Dark, readable color for the actual data */
        font-weight: 500;
        word-wrap: break-word; /* Ensures long addresses or emails wrap correctly */
    }

    /* A subtle loading indicator for a better UX */
    .info-value:empty::after {
        content: "...";
        color: #aaa;
    }

    /* Animation keyframes for the fade-in effect */
    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* =================================== */
    /*       Dashboard & Alert Styles      */
    /* =================================== */

    .alerts-header {
        text-align: center;
        color: #333;
        font-size: 1.8rem;
        font-weight: 600;
        margin: 20px 0;
    }

    .alerts-container {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        padding: 0 10px;
    }

    .alert-card {
        background-color: #ffffff;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        margin-bottom: 20px;
        overflow: hidden; /* Ensures child borders don't spill out */
        animation: fadeIn 0.5s ease-in-out;
    }

    .alert-header {
        background-color: #dc3545;
        color: white;
        padding: 15px 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .alert-message {
        font-weight: 600;
        font-size: 1.1rem;
    }

    .alert-time {
        font-size: 0.85rem;
        opacity: 0.9;
    }

    .alert-body {
        padding: 5px 20px 15px 20px;
    }

    .alert-body .info-item {
        padding: 10px 0;
    }

    .alert-body .info-value a {
        color: #007bff;
        text-decoration: none;
        font-weight: 600;
    }

    .alert-body .info-value a:hover {
        text-decoration: underline;
    }

    /* Pagination Styles */
    .pagination-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px 10px;
        gap: 15px; /* Adds space between buttons and text */
    }

    .pagination-controls button {
        background-color: #007bff;
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 20px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .pagination-controls button:hover {
        background-color: #0056b3;
    }

    .pagination-controls span {
        font-size: 1rem;
        color: #6c757d;
        font-weight: 500;
    }
}

/* =================================== */
/*       Push Notification Button      */
/* =================================== */

.push-controls {
    margin-top: 30px; /* Add space above the button */
    width: 100%;
    display: flex;
    justify-content: center;
}

#subscribeButton {
    /* Make the button much larger and more prominent */
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 220px; /* Ensure a good minimum width */

    /* Style it like a primary action button */
    border: none;
    border-radius: 8px;
    color: white;
    background-color: #007bff; /* A standard 'action' blue color */
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
}

#subscribeButton:hover {
    background-color: #0056b3;
    transform: translateY(-1px); /* Add a slight lift on hover */
}

#subscribeButton:disabled {
    background-color: #28a745; /* Green color for success */
    cursor: not-allowed;
}

/* Style for the "Install App" button */
#installButton {
    background-color: #007bff; /* A different, friendly color */
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    margin-top: 15px; /* Spacing from the login form */
    width: 100%;
    transition: background-color 0.2s;
}

#installButton:hover {
    background-color: #0056b3;
}

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.6); /* Black w/ opacity */
}

/* Modal Content/Box */
.modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 25px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 10px;
    position: relative;
    box-shadow:
        0 4px 8px 0 rgba(0, 0, 0, 0.2),
        0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

/* The Close Button */
.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal h2 {
    margin-top: 0;
    color: #333;
}

.modal p {
    line-height: 1.5;
    color: #555;
}

.instructions h4 {
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-top: 20px;
}

/* Initially hide Android-specific instructions if needed, can be shown with JS */
/* .instruction-android { display: none; } */
