/* Mobile-first CSS - Designed for mobile screens only */
* { box-sizing: border-box; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    font-size: 16px;
    line-height: 1.4;
}

/* Login page styles */
body.login-page { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100vh; 
    background-color: #f0f2f5; 
    padding: 0.5rem;
}

.auth-box { 
    background: white; 
    padding: 2rem; 
    border-radius: 12px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.1); 
    width: 100%;
    max-width: 360px;
}

.logo-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo {
    width: 120px;
    height: 120px;
    max-width: 100%;
    height: auto;
}

h2 { 
    text-align: center; 
    margin: 0 0 1.5rem 0; 
    font-size: 1.5rem;
    color: #333;
}

input { 
    display: block; 
    width: 100%; 
    padding: 0.75rem; 
    margin-bottom: 1rem; 
    border: 2px solid #e1e5e9; 
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    background: #f8f9fa;
}

input:focus {
    outline: none;
    border-color: #007bff;
    background: white;
}

button { 
    width: 100%; 
    padding: 0.875rem; 
    border: none; 
    background-color: #007bff; 
    color: white; 
    border-radius: 8px; 
    cursor: pointer; 
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

/* Override width for specific buttons */
.logout-btn,
.resolve-btn,
.action-btn,
.submit-btn {
    width: auto;
}

button:active { background-color: #0056b3; }

.message { 
    margin-top: 1rem; 
    text-align: center; 
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.error { 
    color: #dc3545; 
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

.success { 
    color: #155724; 
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.toggle-link { 
    text-align: center; 
    margin-top: 1.5rem; 
}

.toggle-link a { 
    color: #007bff; 
    cursor: pointer; 
    text-decoration: none; 
    font-size: 0.9rem;
}

.toggle-link a:active { text-decoration: underline; }

/* Dashboard page styles - Mobile optimized */
body.dashboard-page { 
    background-color: #f8f9fa; 
    margin: 0; 
    padding: 0; 
}

.header { 
    background: white; 
    padding: 1rem; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.header h1 { 
    margin: 0; 
    color: #333; 
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
}

.logout-btn { 
    padding: 0.5rem 0.75rem; 
    background-color: #dc3545; 
    font-size: 0.8rem;
    border-radius: 6px;
    border: none;
    color: white;
    font-weight: 500;
    width: auto;
    min-width: auto;
}

.logout-btn:active { background-color: #c82333; }

.content { 
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Teacher Dashboard Specific Styles */
.groups-container {
    margin-bottom: 2rem;
}

.group-section {
    background: white;
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.group-header {
    background: #007bff;
    color: white;
    padding: 1rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.children-list {
    padding: 0;
}

.child-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background: white;
}

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

.child-info {
    flex: 1;
}

.child-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.child-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-missing {
    background-color: #28a745;
    color: white;
    border: 2px solid #28a745;
}

.btn-missing:hover {
    background-color: #218838;
    border-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-missing:active {
    background-color: #1e7e34;
    border-color: #1e7e34;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-view {
    background-color: #17a2b8;
    color: white;
}

.btn-view:active {
    background-color: #138496;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 2000; /* bigger then menu */
    padding: 0;
}

.modal {
    background: white;
    width: 100%;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.modal.show {
    transform: translateY(0);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.modal-title {
    font-weight: 600;
    color: #333;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1rem;
    max-height: 50vh;
    overflow-y: auto;
}

.items-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.item-checkbox {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
}

.item-checkbox.selected {
    background: #e3f2fd;
    border-color: #2196f3;
}

.item-checkbox input {
    margin-right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
}

/* Calendar input styling */
#absence-calendar {
    cursor: pointer;
    background: white !important;
}

#absence-calendar:focus {
    border-color: #007bff !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* Flatpickr calendar customization */
.flatpickr-calendar {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.flatpickr-day.selected {
    background: #007bff;
    border-color: #007bff;
}

.flatpickr-day.selected:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.flatpickr-day.today {
    border-color: #007bff;
    color: #007bff;
}

/* Weekly Navigation Styles */
.week-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
    gap: 0.5rem;
}

.week-nav-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: auto;
    width: auto;
    flex-shrink: 0;
    max-width: 200px;
}

.week-nav-btn:hover:not(:disabled) {
    background: #0056b3;
}

.week-nav-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.week-display {
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
    text-align: center;
    white-space: nowrap;
    flex: 1;
    margin: 0 1rem;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Responsive week navigation for mobile */
@media (max-width: 768px) {
    .week-navigation {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.75rem;
        border: none;
        background: transparent;
    }
    
    .week-nav-btn {
        width: 48px;
        height: 48px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
        min-width: 48px;
        max-width: 48px;
    }
    
    .week-nav-btn .btn-text {
        display: none;
    }
    
    .week-nav-btn .arrow {
        font-size: 1.2rem;
        font-weight: bold;
    }
    
    .week-display {
        margin: 0;
        flex: 1;
        font-size: 0.9rem;
    }
}

/* Weekly Absences Display */
.weekly-absences {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Absences section - match needs-section styling */
.absences-section {
    padding: 1rem;
}

.date-section {
    background: white;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.date-section:last-child {
    margin-bottom: 0;
}

.date-header {
    background: #e9ecef;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    font-size: 1.1rem;
}

.no-absences {
    padding: 1.5rem;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    background: #f8f9fa;
}

.absences-list {
    padding: 0;
}

.absence-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s;
}

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

.absence-item:hover {
    background: #f8f9fa;
}

.absence-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.absence-child-name {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.absence-reported-date {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: normal;
}

.cancel-absence-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    width: auto;
    min-width: 50px;
}

.cancel-absence-btn:hover:not(:disabled) {
    background: #c82333;
}

.cancel-absence-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.submit-btn {
    width: 100%;
    padding: 0.875rem;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.submit-btn:active {
    background-color: #218838;
}

.submit-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Loading states */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

/* Needs section */
.needs-section {
    padding: 1rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    text-align: center;
}

.needs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.need-item {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.need-item:last-child {
    margin-bottom: 0;
}

.need-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.need-child-name {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
    flex: 1;
    margin-bottom: 0.5rem;
}

.need-date {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    margin-left: 0;
    margin-bottom: 0.25rem;
    font-weight: normal;
}

.need-dates {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.resolved-date {
    color: #28a745;
    font-size: 0.8rem;
    font-style: normal;
    font-weight: normal;
    margin-left: 0;
    margin-top: 0.25rem;
}

.need-items {
    color: #555;
    line-height: 1.5;
}

/* Announcement specific styles */
.need-item.announcement .need-header .need-child-name {
    color: #28a745;
}

.announcement-meta {
    font-size: 0.8rem;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.announcement-author {
    margin-bottom: 0.5rem;
}

.announcement-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.need-tag {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Parent Dashboard Specific Styles */
.children-overview {
    margin-bottom: 2rem;
}

.children-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.child-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.child-card .child-name {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.child-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}



.child-group {
    font-size: 0.85rem;
    color: #007bff;
    font-weight: 500;
}

/* Parent Needs Styles */
.parent-need {
    border-left: 4px solid #ffc107;
}

.need-child-info {
    flex: 1;
}

.resolve-btn {
    padding: 0.5rem 0.75rem;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    min-width: auto;
    white-space: nowrap;
}

.resolve-btn:active {
    background-color: #218838;
}

.need-items-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.need-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.no-needs {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.no-needs p {
    margin: 0;
    font-size: 1.1rem;
}

/* Resolved needs styles for teacher dashboard */
.need-item.resolved {
    background: #d4edda;
    border-left-color: #28a745;
    opacity: 0.8;
}

.need-item.resolved .need-child-name::after {
    content: " ✓";
    color: #28a745;
    font-weight: bold;
}

.need-item.resolved .need-tag {
    background: #c3e6cb;
    color: #155724;
}

.resolved-badge {
    background: #28a745;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.resolved-info {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #d4edda;
}

.resolved-info small {
    color: #6c757d;
    font-style: italic;
}

/* Need actions for teachers */
.need-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.resolve-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.resolve-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.resolve-btn:active {
    background: #1e7e34;
    transform: translateY(0);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding: 10px 0;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 20px));
    z-index: 1000;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    height: 80px;
}

.nav-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 12px;
    text-decoration: none;
    color: #718096;
    padding: 5px;
}

.nav-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.nav-item.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.15);
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 4px;
    line-height: 1;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

/* Add bottom padding to body for bottom nav */
body.dashboard-page {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 20px));
}



/* Mobile responsive for bottom nav */
@media (max-width: 768px) {
    .bottom-nav {
        height: 80px;
        padding: 5px 0;
        padding-bottom: calc(0px + env(safe-area-inset-bottom, 20px));
    }
    
    .nav-container {
        padding: 0 10px;
    }
    
    .nav-icon {
        font-size: 20px;
    }
    
    .nav-label {
        font-size: 10px;
    }
    
    body.dashboard-page {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }
}

/* PWA Install Prompt Styles */
#install-prompt .install-prompt-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    margin-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

#install-prompt .install-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

#install-prompt .install-text h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
    font-size: 1.5rem;
}

#install-prompt .install-text p {
    margin: 0 0 1.5rem 0;
    color: #666;
    line-height: 1.4;
}

#install-prompt .install-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

#install-prompt .install-btn {
    background: #4285f4;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

#install-prompt .install-btn:hover {
    background: #3367d6;
}

#install-prompt .dismiss-btn {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#install-prompt .dismiss-btn:hover {
    background: #e9ecef;
    color: #333;
}

/* iOS Instructions Styles */
#ios-instructions .ios-instructions-content {
    background: #1a1a1a;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
    border: 1px solid #333;
    margin-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

#ios-instructions .ios-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

#ios-instructions h3 {
    margin: 0 0 1rem 0;
    color: white;
    font-size: 1rem;
}

#ios-instructions ol {
    text-align: left;
    margin: 1rem 0;
    padding-left: 1.5rem;
}

#ios-instructions li {
    margin: 0.5rem 0;
    color: #ccc;
    line-height: 1.4;
}

#ios-instructions .close-btn {
    background: #4285f4;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    font-size: 0.9rem;
    min-width: 80px;
    white-space: nowrap;
}

.app-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Share icon styling */
#ios-instructions .share-icon {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #007AFF;
    background: #F2F2F7;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    margin: 0 4px;
}

/* Mobile responsive for install prompt */
@media (max-width: 480px) {
    #install-prompt .install-prompt-content,
    #ios-instructions .ios-instructions-content {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    #install-prompt .install-actions {
        flex-direction: column;
    }
}

/* Floating Install Button */
#floating-install-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4285f4;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
    font-weight: 600;
    font-size: 14px;
    z-index: 1000;
    transition: all 0.3s ease;
    border: none;
    display: none;
}

#floating-install-btn:hover {
    background: #3367d6;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(66, 133, 244, 0.5);
}

#floating-install-btn:active {
    transform: translateY(0);
}

/* iOS safe area for floating button */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #floating-install-btn {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        right: calc(20px + env(safe-area-inset-right, 0px));
    }
}
