/* style.css */

/* ==========================================================
   1. Základní styly a layout
   ========================================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

header {
    display: flex;
    flex-wrap: wrap; 
    justify-content: space-between;
    align-items: center;
    gap: 15px; 
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

h1 {
    margin: 0;
    color: #2c3e50;
}

.header-title-container {
    flex-grow: 1;
}


/* ==========================================================
   2. Tlačítka a ovládací prvky
   ========================================================== */

.sandwich-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 110; /* Musí být vyšší než overlay modálních oken */
}

.sandwich-icon {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.sandwich-icon:hover {
    background-color: #f0f0f0;
}

.sandwich-icon span {
    display: block;
    width: 22px;
    height: 3px;
    background-color: #555;
    border-radius: 3px;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0; /* Zarovnání k pravému okraji */
    top: calc(100% + 5px); /* Pozice pod tlačítkem s mezerou */
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 5px;
    overflow: hidden;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
}

.dropdown-content.show {
    display: block;
}

.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.filters-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.btn {
    background-color: #3498db;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
    white-space: nowrap; 
}
.btn:hover {
    background-color: #2980b9;
}

.btn.btn-small {
    padding: 6px 10px;
    font-size: 14px;
}

#date-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
}
#date-filter-form label {
    font-weight: bold;
    white-space: nowrap;
}
#date-filter-form input[type="date"] {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 5px;
}
.checkbox-wrapper label {
    font-weight: normal !important;
    cursor: pointer;
}
#apply-date-filter {
    cursor: pointer;
}

#tag-search-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
#tag-search-container label {
    font-weight: bold;
    white-space: nowrap;
}
#search-tag-input {
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 200px; 
}

.active-filters {
    background-color: #eaf5fc;
    border: 1px solid #bce8f1;
    color: #31708f;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}
.active-filters p {
    margin: 0;
}
.clear-filter-btn {
    color: #c0392b;
    text-decoration: none;
    font-size: 0.9em;
    margin-left: 10px;
}
.clear-filter-btn:hover {
    text-decoration: underline;
}

.view-switcher {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.btn-view {
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
}
.btn-view.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}


/* ==========================================================
   3. Řádkový přehled (Itinerář)
   ========================================================== */

.itinerary-day h2 {
    color: #3498db;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 5px;
    margin-top: 30px;
    font-size: 1.4em;
}
.itinerary-day.today h2 {
    color: #e67e22;
}

.meal-item {
    display: flex;
    padding: 12px 5px;
    border-bottom: 1px solid #f0f0f0;
    gap: 15px;
    align-items: center;
}
.meal-item:last-child {
    border-bottom: none;
}
.meal-type {
    font-weight: bold;
    width: 90px;
    color: #555;
    flex-shrink: 0; 
}
.meal-name {
    flex-grow: 1;
    font-weight: 500;
}
.meal-side {
    color: #7f8c8d;
    font-style: italic;
    margin-left: 8px;
}
.meal-actions {
    margin-left: auto;
    padding-left: 10px;
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #7f8c8d;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s;
}

.action-btn:hover {
    color: #3498db;
}

.action-btn.delete-btn:hover {
    color: #e74c3c;
}


/* ==========================================================
   4. Modální okna
   ========================================================== */

.modal-overlay {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
}
.modal-content {
    background: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    line-height: 1;
    font-weight: bold;
    color: #aaa;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}
.close-btn:hover {
    color: #333;
}
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
    box-sizing: border-box;
    font-size: 16px;
}


/* ==========================================================
   5. Styly pro externí knihovny
   ========================================================== */

.ui-autocomplete {
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 101 !important;
}
.ui-menu-item {
    padding: 10px;
}

/* --- Styly pro FullCalendar a detailní modální okno --- */
.fc .fc-toolbar.fc-header-toolbar {
    margin-bottom: 1em;
    flex-wrap: wrap; 
}

.fc-event-title {
    white-space: normal !important;
    overflow-wrap: break-word;
}
.fc-daygrid-event {
    align-items: flex-start !important;
    padding: 2px !important;
}

.fc-daygrid-day:hover {
    cursor: pointer;
    background-color: #f8f9fa;
}
.fc-event-meal-type {
    background-color: #eaf5fc;
    color: #31708f;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-bottom: 3px;
    display: inline-block;
}

#day-detail-body {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.day-detail-item {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}
.day-detail-item:last-child {
    border-bottom: none;
}
.day-detail-type {
    font-weight: bold;
    width: 90px;
    color: #3498db;
    flex-shrink: 0;
}
.day-detail-meal {
    flex-grow: 1;
}

/* ==========================================================
   6. Responzivní styly pro mobilní zařízení
   ========================================================== */
@media (max-width: 767px) {
    body {
        padding: 10px;
        -webkit-text-size-adjust: 100%;
    }

    .container {
        padding: 15px;
    }

    header {
        align-items: stretch;
        flex-direction: column;
    }
    
    .header-title-container {
        width: 100%;
        justify-content: center;
    }

    .header-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-container,
    #date-filter-form,
    .view-switcher {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    h1 {
        text-align: center;
        font-size: 1.8em;
    }
    
    #tag-search-container {
        flex-direction: column;
        align-items: stretch;
    }

    #search-tag-input {
        min-width: 0;
    }

    .view-switcher > div {
        display: flex;
        justify-content: center;
        gap: 10px;
        width: 100%;
    }

    .btn-view {
        flex-grow: 1;
    }

    .meal-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .meal-type {
        width: auto;
        font-size: 0.9em;
        padding: 2px 6px;
        background-color: #eee;
        border-radius: 4px;
    }
    
    .meal-actions {
        margin-left: 0;
        padding-left: 0;
        align-self: flex-end;
    }

    .modal-content {
        padding: 20px 15px;
    }
    
    .fc-event-meal-type {
        font-size: 0.75em;
    }
    
    #calendar-container {
        min-height: 65vh; 
    }
}

/* ==========================================================
   7. Styly pro stránku Nastavení
   ========================================================== */

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.settings-section {
    margin-bottom: 40px;
    background-color: #fdfdfd;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.settings-section h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

.table-container {
    overflow-x: auto;
}

.settings-table {
    width: 100%;
    border-collapse: collapse;
}

.settings-table th, .settings-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}

.settings-table thead {
    background-color: #f9f9f9;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
}

.tag-item {
    background-color: #eaf5fc;
    color: #31708f;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tag-item:hover {
    background-color: #d1eafb;
}

.tag-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.edit-tag-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
}
.btn-link {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    text-decoration: underline;
}
.btn-danger {
    background-color: #e74c3c;
}
.btn-danger:hover {
    background-color: #c0392b;
}

@media (max-width: 767px) {
    .settings-header {
        flex-direction: column;
        align-items: center;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .tag-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* Tento blok zajišťuje sloupcové zobrazení tabulky na mobilu */
    .settings-table thead {
        display: none;
    }
    .settings-table, .settings-table tbody, .settings-table tr, .settings-table td {
        display: block;
        width: 100%;
    }
    .settings-table tr {
        margin-bottom: 15px;
        border: 1px solid #eee;
        border-radius: 5px;
        padding: 10px;
    }
    .settings-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px dotted #eee;
    }
    .settings-table td:last-child {
        border-bottom: none;
    }
    .settings-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: calc(50% - 20px);
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
}