/* ================================
   RESPONSIVE CSS - Mobile First
   ================================ */

/* Hamburger Menu Button */
.hamburger-menu {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background-color: #2E2E2E;
    border: 2px solid #ff0000;
    border-radius: 5px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.hamburger-menu:hover {
    background-color: #444;
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #fff;
    margin: 5px 0;
    transition: 0.3s;
    border-radius: 2px;
}

/* Hamburger animation when active */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-6px, 6px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(45deg) translate(-6px, -6px);
}

/* Mobile Menu Overlay */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
}

/* ================================
   TABLET BREAKPOINT (768px)
   ================================ */
@media screen and (max-width: 768px) {
    #body-wrapper {
        width: 95%;
    }
    
    #menu {
        width: 25%;
    }
    
    #main {
        width: 72%;
        margin-left: 3%;
    }
    
    #menu img {
        width: 90%;
    }
    
    table#cards-list td,
    table#cards-list th {
        padding: 8px 4px;
        font-size: small;
    }
    
    table#cards-list td:first-child {
        padding-left: 8px;
    }
}

/* ================================
   MOBILE BREAKPOINT (576px)
   ================================ */
@media screen and (max-width: 576px) {
    /* Show hamburger menu */
    .hamburger-menu {
        display: block;
    }
    
    .menu-overlay {
        display: block;
        pointer-events: none;
    }
    
    .menu-overlay.active {
        pointer-events: auto;
    }
    
    /* Body wrapper full width */
    #body-wrapper {
        width: 100%;
        padding: 0 10px;
        box-sizing: border-box;
    }
    
    /* Sidebar menu - hidden by default, slides in    cor original era #3D2510  */
    #menu {
        position: fixed;
        top: 0;
        left: -280px;
        width: 250px;
        height: 100vh;
        background-color: #f0f0f0;
        z-index: 1000;
        padding: 70px 15px 20px 15px;
        box-sizing: border-box;
        overflow-y: auto;
        transition: left 0.3s ease;
        float: none;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }
    
    #menu.active {
        left: 0;
    }
    
    #menu img {
        width: 100%;
        max-width: 180px;
        height: auto;
        display: block;
        margin: 0 auto;
    }
    
    #menu ul {
        padding: 0;
        margin: 0;
    }
    
    #menu li {
        margin-bottom: 15px;
        text-align: center;
    }
    
    #menu li a {
        display: block;
    }
    
    /* Main content full width */
    #main {
        width: 100%;
        float: none;
        margin-left: 0;
        padding: 60px 5px 20px 5px;
        box-sizing: border-box;
    }
    
    /* Header and footer */
    #header,
    #footer {
        width: 100%;
        padding: 10px;
        box-sizing: border-box;
    }
    
    #footer {
        margin-top: 50px;
        font-size: 12px;
    }
    
    #footer p {
        margin-bottom: 8px;
        line-height: 1.4;
    }
    
    /* Search and filtering */
    #filtering {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0 5px;
    }
    
    #filtering div {
        width: 100%;
    }
    
    label#search-name-label,
    label#search-by-edition-label {
        display: block;
        margin-bottom: 5px;
        font-size: 14px;
    }
    
    input#search-name,
    select#search-by-edition {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        border: 1px solid #444;
        border-radius: 5px;
        box-sizing: border-box;
        background-color: #2E2E2E;
        color: #fff;
    }
    
    button#search-name-button {
        width: 100%;
        padding: 14px;
        margin-top: 10px;
        font-size: 16px;
        touch-action: manipulation;
    }
    
    /* Cards table responsive */
    table#cards-list {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table#cards-list th,
    table#cards-list td {
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    table#cards-list td:first-child {
        padding-left: 10px;
        max-width: 150px;
        white-space: normal;
        word-wrap: break-word;
    }
    
    table#cards-list th {
        font-size: 12px;
        position: sticky;
        top: 0;
        background-color: #333;
    }
    
    /* Pagination */
    #cards-nav-wrapper {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
        padding: 15px 0;
    }
    
    #cards-nav-wrapper button {
        min-width: 50px;
        min-height: 44px;
        padding: 10px 15px;
        font-size: 18px;
    }
    
    .styled-select {
        flex: 1;
        max-width: 120px;
    }
    
    .styled-select select {
        width: 100%;
        padding: 10px;
        font-size: 16px;
        min-height: 44px;
    }
    
    /* Homepage text */
    .h3, .h4 {
        padding: 0 15px;
        line-height: 1.4;
    }
    
    .h4 {
        font-size: 180%;
    }
    
    .h3 {
        font-size: 110%;
    }
    
    /* Buttons touch friendly */
    input[type="submit"],
    .button {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    /* Remove excessive br tags spacing */
    br + br + br {
        display: none;
    }
}

/* ================================
   EXTRA SMALL DEVICES (320px)
   ================================ */
@media screen and (max-width: 380px) {
    #menu {
        width: 220px;
        left: -240px;
    }
    
    #menu img {
        max-width: 150px;
    }
    
    table#cards-list th,
    table#cards-list td {
        padding: 8px 5px;
        font-size: 12px;
    }
    
    .h4 {
        font-size: 150%;
    }
    
    .h3 {
        font-size: 100%;
    }
    
    #cards-nav-wrapper button {
        min-width: 44px;
        padding: 8px 12px;
    }
}

/* ================================
   LANDSCAPE MOBILE
   ================================ */
@media screen and (max-width: 896px) and (orientation: landscape) {
    #menu {
        padding-top: 50px;
    }
    
    #menu li {
        margin-bottom: 10px;
    }
    
    #menu img {
        max-width: 120px;
    }
    
    #main {
        padding-top: 50px;
    }
}

/* ================================
   TOUCH IMPROVEMENTS
   ================================ */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    table#cards-list tr:not(:first-child):hover {
        background-color: transparent;
    }
    
    table#cards-list tr:not(:first-child):active {
        background-color: #CA6666;
    }
    
    #menu li:hover {
        border-left: none;
    }
    
    #menu li:active {
        border-left: solid 2px #ffffff;
    }
    
    input[type="submit"]:hover,
    .button:hover {
        background-color: transparent;
    }
    
    input[type="submit"]:active,
    .button:active {
        background-color: #2E2E2E;
    }
}
