/* World card with semi-transparent background image */
.world-card-bg {
    position: relative;
    background: var(--bg-card);
    overflow: hidden;
}
.world-card-bg::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('/static/images/mchorse.png');
    background-size: 200%;
    background-position: top left;
    opacity: 0.3;
    z-index: 0;
}
.world-card-bg > * {
    position: relative;
    z-index: 1;
}
/* Right-align image, left-align text in welcome banner */
#welcomebanner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
:root {
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --text-light: #e0e0e0;
    --text-muted: #aaaaaa;
    
    /* User Palette */
    --p-forest: #333;
    --p-olive: #5090c5;
    --p-dark-olive: #222; 
    --p-fern: #555;
    --p-green: #5090c5;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-light);
    display: flex; /* Sidebar layout */
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Navigation */
header {
    background: var(--p-dark-olive);
    xwidth: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #000;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    z-index: 10;
}

header nav {
    width: 100%;
    margin-top: 20px;
}

header nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

header nav li {
    width: 100%;
}

header nav a {
    display: block;
    padding: 15px 25px;
    color: #e0e0e0;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

header nav a:hover {
    background-color: var(--p-forest);
    border-left-color: var(--p-green);
    color: #ffffff;
}

/* Main Content Area */
main {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px;
    background-color: var(--bg-dark);
}

h1 {
    color: var(--p-green);
    border-bottom: 2px solid var(--p-fern);
    padding-bottom: 10px;
    margin-bottom: 30px;
}

h2, h3 {
    color: var(--p-olive);
}

a {
    color: var(--p-green);
}

/* Forms & Inputs */
form {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    /* margin: 0 auto; Optional: Center form? User didn't specify, but left aligned in main area is fine. */
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-light);
    font-weight: 500;
}

input[type="checkbox"] + label {
    display: inline-block;
    margin-bottom: 0;
    margin-left: 5px;
    font-weight: normal;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    background-color: #2c2c2c;
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    border-color: var(--p-green);
    outline: none;
    background-color: #333;
}

button, input[type="submit"] {
    background: var(--p-fern);
    color: #ffffff;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    width: 100%;
    transition: background 0.3s;
    font-weight: bold;
}

button:hover, input[type="submit"]:hover {
    background: var(--p-green);
}

/* Utility / Messages */
div[id="message"] {
    margin-top: 20px;
    padding: 10px;
    border-radius: 4px;
}

/* Dashboard Table styling if needed */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    /* overflow: hidden; */
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    background-color: var(--p-forest);
    color: white;
}

tr:hover {
    background-color: rgba(255,255,255,0.05);
}

/* Auth Container for side-by-side login/register */
.auth-container {
    display: flex;
    flex-wrap: wrap;
    gap: 40px 40px; /* 10px horizontal, 40px vertical gap */
    justify-content: center;
    align-items: flex-start;
    margin-top: 20px;
}

.auth-box {
    flex: 1;
    min-width: 250px;
    max-width: 450px;
}

.auth-box form {
    width: 90%;
    max-width: 100%; /* Override default form max-width */
}

/* User Info Sidebar Footer */
.user-sidebar-info {
    margin-top: auto; /* Pushes to bottom of flex column */
    padding: 20px;
    background-color: rgba(0,0,0,0.2);
    font-size: 0.9em;
    color: var(--text-muted);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-sidebar-info strong {
    color: var(--text-light);
    display: block;
    margin-top: 5px;
    word-break: break-all;
}

/* Submenu Styles */
header nav ul.submenu {
    padding-left: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

header nav ul.submenu a {
    padding: 10px 10px 10px 40px; /* Indent */
    font-size: 0.85rem;
    color: var(--text-muted);
    border-left: 4px solid transparent;
}

header nav ul.submenu a:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: transparent;
}

/* Menu Toggle Logic */
.menu-item-wrapper {
    display: block; /* Desktop default */
    width: 100%;
}

.submenu-toggle {
    display: none; /* Hidden on desktop */
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    header {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #000;
        box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    }

    header nav {
        margin-top: 0;
    }

    header nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
        padding: 5px 0;
    }

    header nav li {
        width: auto;
    }

    /* Admin Submenu Handling for Mobile */
    header nav li.has-submenu {
        width: auto; /* Default to auto flow */
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    header nav li.has-submenu.open {
        width: 100%; /* Take full width when expanded */
    }

    .menu-item-wrapper {
        display: flex;
        width: auto;
        align-items: center;
    }

    .menu-item-wrapper a {
        flex-grow: 0;
        border-bottom: 4px solid transparent; 
    }

    .submenu-toggle {
        display: block;
        background: transparent;
        color: var(--text-light);
        border: none;
        font-size: 1.2em;
        padding: 0 10px;
        cursor: pointer;
        height: 100%;
        margin-left: 5px; /* Spacing */
    }

    header nav ul.submenu {
        display: none; /* Hidden by default */
        width: 100%;
        flex-direction: column;
        background-color: rgba(0,0,0,0.2);
    }

    header nav ul.submenu.open {
        display: flex;
    }

    header nav ul.submenu a {
        text-align: left;
        padding-left: 40px;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }

    header nav a {
        padding: 10px 15px;
        text-align: center;
        border-left: none;
        border-bottom: 4px solid transparent;
        font-size: 0.9rem;
    }

    header nav a:hover {
        background-color: var(--p-forest);
        border-left-color: transparent;
        border-bottom-color: var(--p-green);
    }

    main {
        padding: 15px;
    }

    .user-sidebar-info {
        margin-top: 10px; /* Reset from auto */
        padding: 5px;
        text-align: center;
        font-size: 0.85em;
        width: 100%;
        border-top: none;
        background-color: transparent;
    }
    
    .user-sidebar-info br {
        display: none;
    }
    
    .user-sidebar-info strong {
        margin-left: 5px;
        margin-right: 5px;
    }
    
    .user-sidebar-info a {
        display: inline-block !important; /* override inline style from html if possible, but html has style="..." */
        margin-top: 0 !important;
        margin-left: 10px;
    }
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-box {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    min-width: 400px;
    max-width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-box.modal-lg {
    width: 75vw;
}

@media (max-width: 600px) {
    .modal-box {
        min-width: 95%;
        padding: 15px;
    }
}

/* Ensure forms inside modals take full width */
.modal-box form {
    max-width: 100%;
    box-shadow: none;
    background: transparent;
    padding: 0;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #aaa;
}
.close-btn:hover { color: white; }

/* Actions Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    background-color: #444; /* Darker than primary button for 'Actions' */
    color: white;
    padding: 8px 12px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    border-radius: 4px;
}

.dropdown-toggle:hover {
    background-color: #555;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #2c2c2c; /* Matches input bg */
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
    z-index: 999;
    border-radius: 4px;
    border: 1px solid #444;
    overflow: hidden;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu button,
.dropdown-menu a {
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    width: 100%;
    border: none;
    border-radius: 0;
    background: none; /* Reset individual button backgrounds for the list item look? */
    /* User said "Keep the colours as they are." - this might mean the button background colors. */
    /* If I keep the background colors, it will look like a stack of colored blocks. That works. */
    margin: 0;
    font-size: 0.9em;
    cursor: pointer;
    box-sizing: border-box;
}

.dropdown-menu button:hover,
.dropdown-menu a:hover {
    filter: brightness(110%);
}


/* Striped Button (Danger) */
.btn-delete {
    background: repeating-linear-gradient(
        45deg,
        #c0392b,
        #c0392b 10px,
        #e74c3c 10px,
        #e74c3c 20px
    ) !important;
    color: white;
}
.btn-delete:hover {
    filter: brightness(110%);
}
