/* --- Spower Refactored - Main Stylesheet --- */

/* 1. CSS Variables (Custom Properties) for Theming */
:root {
    --primary-color: #005a9c; /* A professional blue */
    --secondary-color: #333;
    --background-color: #f4f7fa;
    --content-bg-color: #ffffff;
    --border-color: #dee2e6;
    --text-color: #333;
    --link-color: #005a9c;
    --link-hover-color: #003d69;
    --header-bg-color: #2c3e50;
    --header-text-color: #ecf0f1;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 4px;
}

/* 2. General Body and Typography Styles */
html {
    margin: 0;
    padding: 0;
    background-color: #ffffff;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

h1, h2, h3 {
    color: var(--secondary-color);
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* 3. Main Layout Containers */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* For pages that use the .page > .content structure */
.page {
    width: 100%;
}

/* 4. Header and Navigation (.topnav) */
.topnav {
    display: flex; /* Use Flexbox for modern layout */
    background-color: var(--header-bg-color);
    overflow: hidden;
    padding: 0 10px;
}

.topnav a {
    color: var(--header-text-color);
    text-align: center;
    padding: 14px 16px;
    font-size: 17px;
    text-decoration: none;
}

.topnav a:hover {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

/* Pushes the logout link to the far right */
.topnav a[href="logout.php"] {
    margin-left: auto;
}

/* --- FIXED LOGIN LAYOUT --- */

/* 1. Force the body to be the full height of the screen and center content */
body.login-page {
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    display: flex;             /* Use Flexbox */
    flex-direction: column;    /* Stack items vertically */
    justify-content: center;   /* Center vertically */
    align-items: center;       /* Center horizontally */
    min-height: 100vh;         /* Use 100% of the browser window height */
}

/* 2. The wrapper for the 4 elements */
body.login-page #main {
    width: 100%;
    max-width: 500px;         /* Keeps the login box a nice professional size */
    display: flex;
    flex-direction: column;    /* Stacks Header, Login, Info, Footer */
    gap: 15px;                 /* Perfectly even spacing between the 4 elements */
    padding: 20px;
    box-sizing: border-box;
}

/* 3. Standardize the Boxes (#login and #info) */
body.login-page #login, 
body.login-page #info {
    background-color: #ffffff;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    width: 100%;               /* Fill the 500px container */
    box-sizing: border-box;
    text-align: left;          /* Text inside stays left-aligned */
}

/* 4. Handle the Banner Images */
body.login-page .login-banner {
    display: block;
    margin: 0 auto;            /* Horizontal centering */
    max-width: 100%;
    height: auto;
}

/* 5. Specific Form Tweaks */
body.login-page #login h3, 
body.login-page #info h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

body.login-page #login form input[type="text"],
body.login-page #login form input[type="password"] {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

body.login-page #login .error {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 10px;
    font-weight: bold;
}

/* Responsive: On small phones, make the container slightly wider */
@media (max-width: 520px) {
    body.login-page #main {
        max-width: 95%;
    }
}

body.login-page #main {
    max-width: 700px;
    margin: 0 auto;
    padding: 0;
    text-align: center;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    row-gap: 20px; /* Re-added row-gap for spacing */
}

body.login-page .header-banner {
    grid-area: header;
}

body.login-page #login {
    grid-area: login;
}

body.login-page #info {
    grid-area: info;
}

body.login-page .footer-banner {
    grid-area: footer;
}

body.login-page .login-banner {
    display: block;
    width: auto; /* Allow image to be naturally sized and centered */
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    padding: 0;
    border: 0;
    vertical-align: top;
}

body.login-page #login,
body.login-page #info {
    display: block;
    vertical-align: top;
    width: auto; /* Allow width to be determined by content, up to max-width of parent */
    max-width: 100%; /* Ensure it doesn't overflow its parent */
    padding: 12px 14px;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 0;
    text-align: left;
    box-sizing: border-box;
}



body.login-page #login h3,
body.login-page #info h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

body.login-page #info p {
    margin: 0 0 6px;
    font-size: 0.95rem;
}

body.login-page #info p:last-child {
    margin-bottom: 0;
}

body.login-page #login form {
    margin-bottom: 0;
}

body.login-page #login form label,
body.login-page #login form input {
    margin-bottom: 6px;
}

body.login-page #login form input[type="text"],
body.login-page #login form input[type="password"] {
    padding: 7px 9px;
}

body.login-page #login form input[type="submit"] {
    margin-top: 2px;
    margin-bottom: 0;
    padding: 8px 12px;
    font-size: 15px;
}

body.login-page #login .error {
    color: #e74c3c;
    margin-top: 6px;
    font-size: 0.9rem;
    min-height: 1.2em;
}

#main {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
    text-align: center;
}

#login, #info {
    display: inline-block;
    vertical-align: top;
    width: 100%;
    margin: 10px auto;
    padding: 20px;
    background-color: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-align: left;
}

#login .error {
    color: #e74c3c;
    margin-top: 10px;
}

/* Feedback messages for user management */
.feedback-success {
    color: #27ae60; /* Green */
    background-color: #e9f7ef;
    border: 1px solid #a3d9b8;
    padding: 10px;
    border-radius: var(--border-radius);
}
.feedback-error {
    color: #c0392b; /* Red */
    background-color: #fbeae9;
    border: 1px solid #f1b0ab;
    padding: 10px;
    border-radius: var(--border-radius);
}

/* 6. Forms (Search, User Management) */
form {
    margin-bottom: 20px;
}

form label, form input, form select, form button {
    display: block;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
}

form input[type="text"],
form input[type="password"],
form select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

form input[type="radio"] {
    display: inline-block;
    width: auto;
    margin-right: 5px;
}

form input[type="submit"],
form button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 15px;
    cursor: pointer;
    border-radius: var(--border-radius);
    font-size: 16px;
}

form input[type="submit"]:hover,
form button:hover {
    background-color: var(--link-hover-color);
}

/* General purpose button styling for <a> tags or other elements */
.button {
    display: inline-block;
    padding: 12px 15px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    border-radius: var(--border-radius);
    border: none;
}
.button-action {
    background-color: var(--primary-color);
    color: white;
}
.button-action:hover { background-color: var(--link-hover-color); color: white; text-decoration: none; }

/* Specific style for the home page search form */
.elegant-aero table {
    border: none;
}
.elegant-aero table td {
    padding: 5px;
    border: none;
}

/* 7. Tables (Results, Users) */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

table th, table td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
}

table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

table tr:nth-child(even) {
    background-color: #f9f9f9;
}

table tr:hover {
    background-color: #f1f1f1;
}

/* Results table: sortable headers and file-group banding */
.results-table tr:nth-child(even),
.results-table tr:nth-child(odd) {
    background-color: transparent;
}

.results-table th.sort-active {
    background-color: #d4e3f2;
}

.results-table th .sort-link {
    color: var(--secondary-color);
    font-weight: bold;
    text-decoration: none;
    display: block;
}

.results-table th .sort-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.results-table tr.file-group-a td {
    background-color: #ffffff;
}

.results-table tr.file-group-b td {
    background-color: #dce8f4;
}

.results-table tr.file-group-start td {
    border-top: 2px solid var(--primary-color);
}

.results-table tr.file-group-a:hover td,
.results-table tr.file-group-b:hover td {
    background-color: #c5daf0;
}

/* 8. Responsive Design */
@media (max-width: 768px) {
    .topnav {
        flex-direction: column; /* Stack nav links vertically */
    }

    .topnav a[href="logout.php"] {
        margin-left: 0; /* Reset margin for stacked layout */
    }

    #login, #info {
        width: 90%; /* Make login boxes full width */
        margin: 10px 0;
    }

    body.login-page #login,
    body.login-page #info {
        width: 100%;
    }


}


