/* Homestay Manager - Main Stylesheet */

/* General Styles */
html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f8fa;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Prevent whole page scroll */
    -webkit-overflow-scrolling: touch;
}

/* Allow text selection in forms and modals */
input, textarea, select, .modal, .form-control {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
}

/* Disable user-select for UI elements only */
button, a, .btn, .sidebar, .navbar {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* PWA App-like behavior */
body {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overscroll-behavior: none; /* Prevent bounce scroll */
    -webkit-overscroll-behavior: none;
}

.content-wrapper {
    padding: 20px;
}

/* Login Page */
.login-page {
    background-color: #3498db;
    background-image: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
    height: 100vh;
}

/* Main wrapper - fixed app layout */
.wrapper {
    display: flex;
    align-items: stretch;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    min-height: 100vh;
    background-color: #2c3e50;
    color: #ecf0f1;
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 1030;
}

.sidebar .sidebar-header {
    padding: 20px;
    background-color: #233140;
}

.sidebar ul.components {
    padding: 20px 0;
    border-bottom: 1px solid #3e5871;
}

.sidebar ul p {
    color: #ecf0f1;
    padding: 10px;
}

.sidebar ul li a {
    padding: 10px 15px;
    font-size: 1.1em;
    display: block;
    color: #ecf0f1;
    text-decoration: none;
    position: relative;
}

.sidebar ul li a:hover {
    color: #2c3e50;
    background-color: #ecf0f1;
}

/* Disabled sidebar links */
.sidebar ul li.disabled-link a {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar ul li.disabled-link a:hover {
    color: #ecf0f1;
    background-color: transparent;
}

.sidebar ul li.active > a,
.sidebar a[aria-expanded="true"] {
    color: #ecf0f1;
    background-color: #3e5871;
}

/* Fixed Sidebar Layout */
#content {
    flex: 1;
    margin-left: 250px;
    background-color: #f5f8fa;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    -webkit-overflow-scrolling: touch;
    position: relative;
    transition: margin-left 0.3s ease;
}

#content .container-fluid {
    padding: 20px;
    min-height: calc(100vh - 40px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1020;
}

.sidebar-overlay.active {
    display: block;
}

body.no-scroll {
    overflow: hidden;
}

/* Dashboard Cards */
.dashboard-card {
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: all 0.3s;
    background-color: #fff;
}

.dashboard-card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
}

.dashboard-card .card-icon {
    font-size: 2.5em;
    margin-bottom: 15px;
}

.stat-card {
    text-align: center;
}

/* Calendar Styles */
.calendar-wrapper {
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    padding: 20px;
}

.calendar-day {
    position: relative;
    height: 80px;
    border: 1px solid #ddd;
    padding: 5px;
    transition: all 0.2s;
}

.calendar-day:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}

.calendar-day.today {
    background-color: #f0f8ff;
    border: 1px solid #3498db;
}

.calendar-day .day-number {
    position: absolute;
    top: 5px;
    right: 5px;
    font-weight: bold;
}

/* Task status colors */
.status-green {
    background-color: rgba(46, 204, 113, 0.2);
    border-left: 4px solid #2ecc71;
}

.status-red {
    background-color: rgba(231, 76, 60, 0.2);
    border-left: 4px solid #e74c3c;
}

.status-yellow {
    background-color: rgba(241, 196, 15, 0.2);
    border-left: 4px solid #f1c40f;
}

.status-blue {
    background-color: rgba(52, 152, 219, 0.2);
    border-left: 4px solid #3498db;
}

.status-grey {
    background-color: rgba(189, 195, 199, 0.2);
    border-left: 4px solid #bdc3c7;
}

/* Task List */
.task-list {
    list-style: none;
    padding: 0;
}

.task-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item .task-name {
    flex-grow: 1;
}

.task-item .task-status {
    margin-left: 10px;
    display: flex;
}

/* Task Modal */
.task-modal .modal-header {
    background-color: #3498db;
    color: white;
}

.problem-form {
    display: none;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    margin-top: 10px;
}

/* Task Completion Status */
.completion-percentage {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.9em;
    font-weight: bold;
    margin-left: 10px;
}

.percentage-high {
    background-color: #d5f5e3;
    color: #27ae60;
}

.percentage-medium {
    background-color: #fcf3cf;
    color: #f39c12;
}

.percentage-low {
    background-color: #fadbd8;
    color: #c0392b;
}

.percentage-none {
    background-color: #eaecee;
    color: #7f8c8d;
}

/* Tables */
.table-responsive {
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    padding: 20px;
}

/* Forms */
.form-wrapper {
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    padding: 20px;
    margin-bottom: 20px;
}

/* Image Upload Preview */
.image-preview {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    margin-top: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

/* Responsive Adjustments */
@media (max-width: 991.98px) {
    #content {
        margin-left: 0 !important;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    #sidebarCollapse span {
        display: none;
    }
    /* Ensure content starts below the toggle button and add breathing room */
    #sidebarCollapse {
        margin-bottom: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    #content > .container-fluid:first-child {
        margin-top: 16px;
    }
}

/* Custom Checkbox for Task Completion */
.task-checkbox {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
}

.task-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
border-radius: 4px;
}

.task-checkbox:hover input ~ .checkmark {
background-color: #ccc;
}

.task-checkbox input:checked ~ .checkmark {
    background-color: #2ecc71;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.task-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.task-checkbox .checkmark:after {
    left: 9px;
    top: 5px;
    width: 7px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/* Problem Button */
.btn-problem {
    color: #fff;
    background-color: #e74c3c;
    border-color: #c0392b;
}

.btn-problem:hover {
    background-color: #c0392b;
}

/* Notifications */
.notification-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Footer */
.footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    text-align: center;
    padding: 15px 0;
    margin-top: 20px;
}

/* PWA App-like scrolling and touch behavior */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.375rem;
}

/* Prevent pull-to-refresh and overscroll */
@media (max-width: 991.98px) {
    body {
        overscroll-behavior-y: none;
        -webkit-overscroll-behavior-y: none;
        touch-action: pan-x pan-y;
    }
    
    #content {
        overscroll-behavior: none;
        -webkit-overscroll-behavior: none;
    }
}

/* Mobile-only top safe space and toggle button spacing */
@media (max-width: 576px) {
    /* Add a small safe space at the very top for Android webapp status bar */
    .wrapper {
        padding-top: env(safe-area-inset-top, 6px);
    }

    /* Ensure first page section starts slightly below the toggle button */
    #content > .container-fluid:first-child {
        margin-top: 8px;
    }

    /* Give the toggle button extra breathing room below */
    #sidebarCollapse {
        margin-bottom: 12px !important;
    }
}

/* Prefer device safe-area if available (PWA/immersive) */
@supports (padding: env(safe-area-inset-top)) {
    @media (max-width: 576px) {
        .wrapper {
            padding-top: calc(env(safe-area-inset-top) + 6px);
        }
    }
}
