/* Responsive CSS for Kolibrizentrale */

/* Base styles that apply to all screen sizes */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

/* Responsive navigation bar */
.nav-bar {
    background-color: #333;
    margin-bottom: 20px;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.nav-bar::after {
    content: "";
    display: table;
    clear: both;
}

.nav-bar a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 16px;
}

.nav-bar a.active {
    background-color: #4CAF50;
}

.nav-bar a:hover {
    background-color: #4CAF50;
}

.nav-bar a.nav-right {
    float: right;
}

/* Hamburger menu button */
#hamburger-button {
    display: none;
    cursor: pointer;
    padding: 14px 16px;
    background-color: #333;
    color: white;
    font-size: 20px;
    border: none;
    text-align: left;
}

#hamburger-button.active {
    background-color: #4CAF50;
}

#hamburger-button:hover {
    background-color: #4CAF50;
}

/* Responsive tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

/* Table styling with thin borders */
table {
    border-collapse: collapse;
    width: 100%;
}

table, th, td {
    border: 1px solid #ddd;
}

th, td {
    padding: 8px;
    text-align: left;
}

/* Responsive forms */
.form-group {
    margin-bottom: 15px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 8px;
    font-size: 16px; /* Larger font size for better touch interaction */
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Responsive buttons */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    color: #fff;
    background-color: #4CAF50;
    border-color: #4CAF50;
}

.btn-secondary {
    color: #333;
    background-color: #f2f2f2;
    border-color: #ddd;
}

.btn-danger {
    color: #fff;
    background-color: #F44336;
    border-color: #F44336;
}

.btn-info {
    color: #fff;
    background-color: #2196F3;
    border-color: #2196F3;
}

/* Responsive modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 5px;
    position: relative;
    box-sizing: border-box;
}

.modal-close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

/* Media queries for different screen sizes */

/* Small devices (phones, 576px and down) */
@media (max-width: 576px) {
    body {
        margin: 10px;
        padding-top: 50px; /* Add padding to account for fixed navigation bar */
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    /* Hamburger menu for small screens */
    #hamburger-button {
        display: block;
        width: 100%;
        text-align: left;
    }

    .nav-bar {
        position: fixed;
        top: 0;
        box-shadow: 0px 4px 6px rgba(0,0,0,0.1);
        z-index: 1000;
        width: 100%;
    }

    /* Hide navigation items by default on small screens, except view toggle */
    .nav-bar a:not(#hamburger-button) {
        display: none;
        float: none;
        width: 100%;
        text-align: left;
    }

    /* Keep view toggle visible and position it on the right */
    .nav-bar .view-toggle-container {
        display: flex;
        position: absolute;
        right: 0;
        top: 0;
        width: auto;
        height: auto;
        padding: 14px 16px;
        align-items: center;
    }

    /* Show navigation items when expanded */
    .nav-bar.nav-expanded a:not(#hamburger-button) {
        display: block;
    }

    /* Keep view toggle in the upper right corner even when menu is expanded */
    /* We're removing the rules that would reposition the view toggle when menu is expanded */

    .nav-bar a.nav-right {
        float: none;
    }

    /* These styles are now handled by the rules above */

    /* Adjust table display for small screens */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
    }

    td:before {
        position: absolute;
        top: 6px;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        content: attr(data-label);
        /* Ensure all data labels have consistent styling regardless of parent td class */
        text-align: left;
        font-family: Arial, sans-serif;
    }

    /* Make buttons full width on small screens */
    .btn {
        display: block;
        width: 100%;
        margin-right: 0;
    }

    /* Adjust modal for small screens */
    .modal-content {
        width: 95%;
        max-width: 100%;
        margin: 5% auto;
        padding: 15px;
    }

    /* Additional adjustments for very small screens */
    @media (max-width: 400px) {
        .modal-content {
            width: 90%;
            margin: 10% auto;
            padding: 10px;
        }

        /* Improve text display in modals on small screens */
        .modal-content h2 {
            font-size: 1.2rem;
            margin-top: 5px;
            margin-bottom: 10px;
        }

        .modal-content h3 {
            font-size: 1.1rem;
            margin-top: 10px;
            margin-bottom: 5px;
        }

        /* Ensure form elements are properly sized */
        .modal-content input,
        .modal-content select,
        .modal-content textarea {
            font-size: 16px; /* Prevents iOS zoom */
            max-width: 100%;
            box-sizing: border-box;
        }

        /* Handle long text content */
        .modal-content p,
        .modal-content .detail-value {
            word-break: break-word;
            overflow-wrap: break-word;
        }
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 577px) and (max-width: 768px) {
    /* Add margin to body for medium screens */
    body {
        margin: 0 20px;
    }

    /* Adjust navigation for medium screens */
    .nav-bar a {
        padding: 10px 12px;
    }

    /* Adjust buttons for medium screens */
    .btn {
        padding: 0.4rem 0.8rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 769px) and (max-width: 1199px) {
    /* Add margin to body for large screens */
    body {
        margin: 0 40px;
    }

    /* Navigation bar can use float on larger screens */
    .nav-bar a {
        float: left;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    /* Add larger margin to body for extra large screens */
    body {
        margin: 0 80px;
    }

    /* Navigation bar can use float on larger screens */
    .nav-bar a {
        float: left;
    }
}

/* Chart container responsiveness */
.chart-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 30px auto;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
    box-sizing: border-box;
}

/* Footer responsiveness */
footer {
    margin-top: 30px;
    padding: 15px;
    text-align: center;
    border-top: 1px solid #ddd;
    color: #666;
}
