﻿/* ==========================================================================
   TravianP - Responsive Mobile Layout & Dimensions (modeled from astatar2)
   Strictly preserving all existing TravianP asset paths & routes
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Desktop Defaults (Hidden elements on large screens)
   -------------------------------------------------------------------------- */
#UBar {
    display: none;
}

.menu-buttons {
    display: none;
}

.hammenu {
    display: none;
}

.blackShadow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   2. Modern Village Modal (Works on both Desktop & Mobile)
   -------------------------------------------------------------------------- */
.v-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999998;
    display: none;
}

.v-modern-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 92%;
    max-width: 480px;
    max-height: 85vh;
    background: linear-gradient(145deg, #1c261d, #273829);
    border: 2px solid #54c571;
    border-radius: 18px;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8);
    overflow-y: auto;
    padding: 18px;
    direction: rtl;
    color: #ffffff;
}

.v-modern-modal.show-modal {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.v-modal-title {
    color: #54c571;
    text-align: center;
    font-size: 20px;
    margin: 5px 0 15px 0;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(84, 197, 113, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.v-modal-close {
    position: absolute;
    top: 14px;
    left: 14px;
    color: #ff4d4d;
    font-size: 18px;
    cursor: pointer;
    background: rgba(255, 0, 0, 0.15);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.v-modal-close:hover {
    background: rgba(255, 0, 0, 0.4);
    transform: scale(1.1);
    color: #fff;
}

.modern-vtable {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
}

.modern-vtable thead {
    display: none;
}

.modern-vtable tr {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}

.modern-vtable td {
    padding: 8px 10px !important;
    color: #fff !important;
    font-size: 14px !important;
    border: none !important;
}

.modern-vtable td.link a {
    color: #71d000 !important;
    font-weight: bold;
    font-size: 15px;
    text-decoration: none;
}

.modern-vtable td.link a:hover {
    color: #a6ff33 !important;
}

.modern-vtable td.dot.hl {
    color: #ffcc00 !important;
    font-weight: bold;
}

/* --------------------------------------------------------------------------
   3. Mobile Media Queries (max-width: 768px & 900px)
   -------------------------------------------------------------------------- */
@media screen and (max-width: 900px) {
    /* Bottom Floating Action Button & Menu */
    .menu-buttons {
        position: fixed;
        bottom: 72px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1101;
        display: flex;
    }

    .menu-buttons button {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: linear-gradient(135deg, #e5e7eb 0%, #22c55e 40%, #16a34a 100%);
        border: 2px solid #ffffff;
        color: #ffffff;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
        font-size: 18px;
        font-weight: 900;
        cursor: pointer;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        transition: all 0.25s ease;
    }

    .menu-buttons button:hover {
        transform: scale(1.1);
    }

    .hammenu {
        position: fixed;
        bottom: 15px;
        left: 50%;
        transform: translateX(-50%) translateY(120%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.35s ease;
        background-color: rgba(240, 245, 240, 0.95);
        border: 1px solid rgba(0, 0, 0, 0.15);
        border-radius: 18px;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 12px;
        justify-items: center;
        align-items: center;
        padding: 8px 14px;
        z-index: 1000;
        width: auto;
        min-width: 270px;
        max-width: 95vw;
    }

    .hammenu.show {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .hammenu img.leftham,
    .hammenu img._lefthamm,
    .hammenu img.war-icon {
        width: 34px !important;
        height: 34px !important;
        border-radius: 50%;
        background: #fff;
        object-fit: contain;
        cursor: pointer;
        padding: 2px;
        border: 1px solid #c0d8c0;
        transition: transform 0.15s;
    }

    .hammenu img:hover {
        transform: scale(1.15);
    }
}

@media screen and (max-width: 768px) {
    /* Upper Navigation Bar (UBar) */
    #UBar {
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        direction: rtl;
        position: fixed;
        margin: 0 !important;
        padding: 4px 8px;
        width: 100%;
        top: 0;
        right: 0;
        z-index: 10000;
        background: linear-gradient(to top, #f5f5f5, #ffffff);
        border-bottom: 1px solid #ccc;
        font-weight: bold;
        font-size: 13px;
        height: 32px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.15);
        box-sizing: border-box;
    }

    #UBar a {
        color: #222;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        font-size: 13px;
    }

    #UBar button.Main {
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 2px;
        display: flex;
        align-items: center;
    }

    #UBar .Gold1 {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        color: #b87333;
        font-weight: bold;
    }

    /* Page Canvas and Wrapper Dimensions */
    html, body {
        width: 100% !important;
        overflow-x: hidden !important;
        direction: rtl !important;
    }

    .wrapper {
        top: 36px !important;
        width: 100% !important;
        min-width: unset !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding: 0 !important;
        margin: 0 auto !important;
    }

    div#dynamic_header {
        display: none !important;
    }

    div#header {
        width: 100% !important;
    }

    div#mtop {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
        right: unset !important;
        margin: 5px auto !important;
        float: none !important;
    }

    div#mtop a#plus {
        display: none !important;
    }

    div#mid {
        width: 100% !important;
        min-width: unset !important;
        direction: rtl !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Side Nav Drawer for Mobile */
    #side_navi {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        width: 75% !important;
        max-width: 320px !important;
        height: 100% !important;
        z-index: 10001 !important;
        background: #ffffff !important;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5) !important;
        overflow-y: auto !important;
        display: none;
        padding: 20px 15px 60px 15px !important;
        direction: rtl !important;
        text-align: right !important;
    }

    #side_navi a {
        display: block !important;
        padding: 8px 12px !important;
        font-size: 15px !important;
        line-height: 24px !important;
        border-bottom: 1px solid #eee !important;
        color: #333 !important;
        text-decoration: none !important;
    }

    #side_navi a:hover {
        background-color: #f0f7f0 !important;
        color: #54c571 !important;
    }

    #side_info {
        display: none !important;
    }

    /* Content Area Dimensions */
    div#content {
        width: 98% !important;
        min-width: unset !important;
        max-width: 100% !important;
        padding: 10px 4px 60px 4px !important;
        margin: 0 auto !important;
        float: none !important;
        overflow-x: auto !important;
        box-sizing: border-box !important;
    }

    /* Village 1 & 2 Map Dimensions */
    div.village1 div#village_map {
        float: none !important;
        margin: 10px auto !important;
        display: block !important;
        max-width: 100% !important;
    }

    div.village1 div#map_details {
        float: none !important;
        width: 95% !important;
        margin: 10px auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    div.village2 div#village_map {
        position: relative !important;
        left: unset !important;
        right: unset !important;
        transform: none !important;
        margin: 10px auto !important;
        display: block !important;
        max-width: 100% !important;
    }

    /* Map page centering */
    div.map div#map {
        position: relative !important;
        left: unset !important;
        transform: none !important;
        margin: 10px auto !important;
    }

    /* Resource Bar Responsiveness */
    div#res {
        position: relative !important;
        top: 0 !important;
        right: unset !important;
        left: unset !important;
        margin: 5px auto !important;
        width: 98% !important;
    }

    div#resWrap {
        width: 100% !important;
    }

    div#res table {
        width: 100% !important;
        margin: 0 auto !important;
    }

    div#res table td.res {
        font-size: 11px !important;
        padding: 2px !important;
    }

    /* Tables & Inputs Responsiveness */
    table#building_contract {
        width: 100% !important;
    }

    div#build {
        width: 100% !important;
        padding: 0 !important;
    }

    div.plus div#products {
        width: 100% !important;
        padding-right: 0 !important;
    }

    /* Footer adjustments */
    #footer, #ltime, .time_of_day {
        display: none !important;
    }
}