@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap');

/* --- GLOBAL VARS --- */
:root {
    --color-bg-dark: #101010;
    --color-bg-panel: #1a1a1a;
    --color-bg-card: rgba(255, 255, 255, 0.03);

    --color-primary: #FF7A00;
    /* Orange AME */
    --color-secondary: #FFD400;
    /* Yellow AME */
    --color-accent: #1E6AFF;
    /* Blue AME */

    --color-text: #f0f0f0;
    --color-text-muted: #888;

    --font-main: 'Rajdhani', sans-serif;
}

/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Rajdhani', sans-serif;
    color: var(--color-text);
    background-color: #000;
    font-size: 23px;
    /* RESTORED USER PREFERENCE */
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Force headings to white/text color unless overridden */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-text);
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* --- COMBO MAP STYLES (Added) --- */
/* --- COMBO MAP STYLES (Added) --- */
.map256 {
    width: 512px;
    height: 512px;
    background-color: #000;
    position: relative;
    border: 2px solid #00589C;
    margin: 0 auto;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

.submark {
    position: absolute;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #00589C;
    border-radius: 6px;
    color: #fff;
    font-weight: bold;
    font-size: 26px;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    border: 1px solid #fff;
    z-index: 20;
}

.parcel-rect {
    position: absolute;
    background: rgba(30, 106, 255, 0.3);
    border: 1px solid #1E6AFF;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.parcel-rect:hover {
    background: rgba(255, 212, 0, 0.4);
    border-color: #FFD400;
    cursor: pointer;
    z-index: 10;
}

.set-item-active {
    border-left: 3px solid #00ff88;
}

.set-item-inactive {
    border-left: 3px solid #444;
}

details summary {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    border-radius: 4px;
    position: relative;
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary:after {
    content: "+";
    position: absolute;
    right: 10px;
    color: var(--color-primary);
    font-weight: bold;
}

details[open] summary:after {
    content: "-";
}

/* --- LOGIN PAGE --- */
.login-body {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #222 0%, #000 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid #333;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(255, 122, 0, 0.1);
}

/* --- LAYOUT --- */
/* --- LAYOUT: FLEXBOX SOLID BLOCKS --- */
.app-container {
    display: flex !important;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* SIDEBAR: FIXED BLOCK */
.sidebar {
    width: 250px !important;
    min-width: 250px !important;
    background: var(--color-bg-panel);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100vh;
    /* Fixed position - sidebar stays in place while content scrolls */
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: 2000;
    overflow: hidden;
    /* NO SCROLL - Fixed sidebar */
}

.brand {
    font-size: 35px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0px;
    /* Menu completamente in alto */
    text-align: center;
    letter-spacing: 1px;
}

.brand span {
    color: var(--color-secondary);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    overflow: hidden;
    /* NO SCROLL on nav-links either */
}

.nav-item a {
    display: block;
    padding: 12px 15px;
    border-radius: 8px;
    color: var(--color-text-muted);
    font-weight: 500;
    border: 1px solid transparent;
    white-space: nowrap;
}

.nav-item a:hover,
.nav-item a.active {
    background: rgba(255, 122, 0, 0.1);
    color: #fff;
    border-color: rgba(255, 122, 0, 0.3);
}

.nav-submenu {
    padding-left: 15px;
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-left: 1px solid #333;
    margin-left: 10px;
}

.nav-submenu a {
    font-size: 0.9em;
    padding: 8px 12px;
    border: none;
    color: #888;
}

.nav-submenu a:hover,
.nav-submenu a.active {
    color: var(--color-primary);
    background: transparent;
    border: none;
    padding-left: 15px;
}

/* MAIN CONTENT */
/* MAIN CONTENT */
/* MAIN CONTENT: FLEX ITEM */
.main-content {
    flex-grow: 1;
    /* Takes remaining space */
    padding: 40px;
    position: relative !important;
    overflow-y: auto;
    /* LEFT MARGIN for fixed sidebar */
    margin-left: 250px !important;
    width: auto !important;
    min-height: 100vh;
    z-index: 0;
}

/* FRAME OFFSET FIX */
.main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 250px;
    /* Still matches sidebar width */
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5000 !important;
    display: block !important;
    /* Animation and Color defined in nav.php/inline */
}

/* ENVIRONMENT FRAME BASE STYLES */
.main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5000 !important;
    display: block !important;
    /* Animation and Color defined in nav.php/inline */
}

.main-content>* {
    position: relative;
    z-index: 10;
}

/* --- COMPONENTS --- */
.card {
    background: var(--color-bg-card);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.bg-gradient {
    background: linear-gradient(135deg, rgba(255, 122, 0, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
}

h1,
h2,
h3 {
    margin-top: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

h1 {
    color: #fff;
    font-size: 41px;
}

/* BUTTONS */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 20px;
    border: none;
    transition: transform 0.1s, box-shadow 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(90deg, var(--color-primary), #ff9900);
    color: #000;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 17px;
}

.btn-secondary {
    background: #333;
    color: #fff;
    border: 1px solid #555;
}

.btn-danger {
    background: #ff3333;
    color: #fff;
}

/* FORMS */
input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px;
    background: #000;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    font-family: inherit;
}

input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* TABLES */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    color: var(--color-text-muted);
    font-size: 14px;
    text-transform: uppercase;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* BADGES */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
}

.badge-on {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid #00ff88;
}

/* --- UTILS --- */
[hidden] {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* --- TOAST --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    min-width: 250px;
    background: #1a1a1a;
    border-left: 4px solid var(--color-primary);
    color: #fff;
    padding: 15px 20px;
    margin-top: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease-out forwards;
}

.toast.success {
    border-color: #00589C;
}

.toast.error {
    border-color: #ff3333;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* PENDING BLINK ANIMATION */
@keyframes pendingBlink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0.3;
    }
}

.pending-blink {
    animation: pendingBlink 1s infinite;
    color: #ff5722 !important;
    font-weight: bold;
}

/* HOURGLASS SPINNING ANIMATION */
@keyframes hourglassSpin {
    0% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(180deg);
    }

    50% {
        transform: rotate(180deg);
    }

    75% {
        transform: rotate(360deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.rez-pending-hourglass {
    display: inline-block;
    animation: hourglassSpin 2s ease-in-out infinite;
    font-size: inherit;
    cursor: not-allowed;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid #333;
        display: none;
    }

    /* Hidden by default mobile */
    .sidebar.active {
        display: flex;
    }

    .menu-toggle {
        display: block;
        position: absolute;
        top: 20px;
        left: 20px;
        cursor: pointer;
        z-index: 1000;
        font-size: 24px;
    }

    .main-content {
        padding: 60px 20px 20px 20px;
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
    }

    .sidebar {
        display: flex !important;
    }
}