/* App shell layout - eliminates top/bottom gaps - Theme aware */
html, body { 
  height: 100%; 
  margin: 0; 
  padding-top: 0 !important; 
}
html[data-bs-theme="dark"], html[data-bs-theme="dark"] body { 
  background: #0f172a; 
}
html[data-bs-theme="light"], html[data-bs-theme="light"] body { 
  background: #ffffff; 
}
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
#site-nav { flex: 0 0 auto; margin-bottom: 0 !important; }

/* Aggressively eliminate all top spacing */
html, body { 
  padding-top: 0 !important; 
  margin-top: 0 !important;
}

header#site-nav { 
  margin-bottom: 0 !important; 
  padding-bottom: 0 !important;
}

#page-root {
  display: flow-root;
  flex-direction: column; 
  flex: 1 1 auto;
  padding-top: 0 !important;
  margin-top: 0 !important;
  border-top: none !important;
}
html[data-bs-theme="dark"] #page-root {
  background: #0f172a;
}
html[data-bs-theme="light"] #page-root {
  background: #ffffff;
}

#ack-page-root {
  display: flow-root;
  padding-top: 0 !important;
  margin-top: 0 !important;
  padding-block-start: 0 !important;
  margin-block-start: 0 !important;
}

/* Zero all container spacing */
#ack-page-root > .container {
  padding-top: 0 !important;
  margin-top: 0 !important;
  padding-block-start: 0 !important;
  margin-block-start: 0 !important;
}

/* Clean acknowledge page layout - no Bootstrap conflicts */
.ack-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem 1rem;
}
html[data-bs-theme="dark"] .ack-container {
    background: #0f172a;
}
html[data-bs-theme="light"] .ack-container {
    background: #ffffff;
}

.ack-card {
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}
html[data-bs-theme="dark"] .ack-card {
    background: #1e293b;
    border: 1px solid #334155;
}
html[data-bs-theme="light"] .ack-card {
    background: #ffffff;
    border: 1px solid #dee2e6;
}

.ack-card:first-child {
    margin-top: 0;
}

.ack-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #334155;
    border-radius: 0.375rem 0.375rem 0 0;
}
html[data-bs-theme="dark"] .ack-header {
    background: #1e293b;
    border-bottom: 1px solid #334155;
}
html[data-bs-theme="light"] .ack-header {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.ack-header h5, .ack-header h6 {
    margin: 0;
    font-weight: 600;
}
html[data-bs-theme="dark"] .ack-header h5, 
html[data-bs-theme="dark"] .ack-header h6 {
    color: white;
}
html[data-bs-theme="light"] .ack-header h5, 
html[data-bs-theme="light"] .ack-header h6 {
    color: #333;
}

/* Child selection cards - theme aware styling */
.child-selection-card {
    border: 1px solid;
}

html[data-bs-theme="dark"] .child-selection-card {
    background-color: #495057;
    border-color: #6c757d;
}

html[data-bs-theme="light"] .child-selection-card {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

/* Child card text styling */
html[data-bs-theme="dark"] .child-icon {
    color: #e9ecef;
}

html[data-bs-theme="light"] .child-icon {
    color: #495057;
}

/* General card styling - theme aware for ALL cards */
html[data-bs-theme="dark"] .card {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

html[data-bs-theme="light"] .card {
    background-color: #ffffff;
    border-color: #dee2e6;
    color: #212529;
}

html[data-bs-theme="dark"] .card-body {
    background-color: #1e293b;
    color: #e2e8f0;
}

html[data-bs-theme="light"] .card-body {
    background-color: #ffffff;
    color: #212529;
}

html[data-bs-theme="dark"] .card-header {
    background-color: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

html[data-bs-theme="light"] .card-header {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #212529;
}

html[data-bs-theme="dark"] .child-name {
    color: #e9ecef;
}

html[data-bs-theme="light"] .child-name {
    color: #212529;
}

html[data-bs-theme="dark"] .child-age {
    color: #e9ecef;
}

html[data-bs-theme="light"] .child-age {
    color: #6c757d;
}

/* Chat navigation buttons - theme aware */
.chat-back-btn {
    border-width: 1px;
}

html[data-bs-theme="dark"] .chat-back-btn {
    color: #e9ecef;
    border-color: #6c757d;
}

html[data-bs-theme="dark"] .chat-back-btn:hover {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

html[data-bs-theme="light"] .chat-back-btn {
    color: #495057;
    border-color: #6c757d;
}

html[data-bs-theme="light"] .chat-back-btn:hover {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

/* Calendar day container styling - theme aware */
.calendar-day-container {
    border: 1px solid var(--bs-border-color);
}

html[data-bs-theme="dark"] .calendar-day-container {
    background-color: #495057;
    border-color: #6c757d;
}

html[data-bs-theme="light"] .calendar-day-container {
    background-color: #ffffff;
    border-color: #dee2e6;
}

/* Mobile profile panel - Complete styling with positioning and animation */
@media (max-width: 768px) {
    .mobile-profile-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        display: block !important;
    }
    
    .mobile-profile-panel.show {
        transform: translateY(0);
    }
    
    .mobile-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-backdrop.show {
        opacity: 1;
        visibility: visible;
    }
}

@media (min-width: 769px) {
    .mobile-profile-panel {
        display: none !important;
    }
    
    .mobile-backdrop {
        display: none !important;
    }
}

/* Mobile profile panel theme styling */
html[data-bs-theme="dark"] .mobile-profile-panel {
    background: var(--bs-dark);
    color: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

html[data-bs-theme="light"] .mobile-profile-panel {
    background: #ffffff;
    color: #212529;
    border: 1px solid #dee2e6;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

html[data-bs-theme="dark"] .mobile-profile-header {
    background: var(--bs-dark);
    border-bottom: 1px solid #495057;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: 20px 20px 0 0;
}

html[data-bs-theme="light"] .mobile-profile-header {
    background: #ffffff;
    border-bottom: 1px solid #dee2e6;
    color: #212529;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: 20px 20px 0 0;
}

.mobile-profile-header h6 {
    margin: 0;
}

html[data-bs-theme="dark"] .mobile-profile-content {
    background: var(--bs-dark);
    color: var(--bs-light);
    padding: 1.5rem;
}

html[data-bs-theme="light"] .mobile-profile-content {
    background: #ffffff;
    color: #212529;
    padding: 1.5rem;
}

html[data-bs-theme="dark"] .mobile-profile-content strong {
    color: #ecf0f1;
}

html[data-bs-theme="light"] .mobile-profile-content strong {
    color: #212529;
}

html[data-bs-theme="dark"] .mobile-profile-content p {
    color: #bdc3c7;
}

html[data-bs-theme="light"] .mobile-profile-content p {
    color: #6c757d;
}

/* Schedule form card styling - theme aware (specific to schedule forms, not dashboard) */
html[data-bs-theme="dark"] .schedule-form-container .card,
html[data-bs-theme="dark"] .card.schedule-card {
    background-color: #495057;
    border-color: #6c757d;
    color: #e9ecef;
}

html[data-bs-theme="light"] .schedule-form-container .card,
html[data-bs-theme="light"] .card.schedule-card {
    background-color: #ffffff;
    border-color: #dee2e6;
    color: #212529;
}

html[data-bs-theme="dark"] .schedule-form-container .card-header,
html[data-bs-theme="dark"] .card.schedule-card .card-header {
    background-color: #3a424a;
    border-bottom-color: #6c757d;
    color: #e9ecef;
}

html[data-bs-theme="light"] .schedule-form-container .card-header,
html[data-bs-theme="light"] .card.schedule-card .card-header {
    background-color: #f8f9fa;
    border-bottom-color: #dee2e6;
    color: #212529;
}

/* Parent dashboard cards - theme-aware styling */
html[data-bs-theme="dark"] .parent-dashboard-card {
    background-color: #495057 !important;
    border-color: #6c757d !important;
    color: #e9ecef !important;
}

html[data-bs-theme="light"] .parent-dashboard-card {
    background-color: #ffffff !important;
    border-color: #dee2e6 !important;
    color: #212529 !important;
}

html[data-bs-theme="dark"] .parent-dashboard-card .card-header {
    background-color: #3a424a !important;
    border-bottom-color: #6c757d !important;
    color: #e9ecef !important;
}

html[data-bs-theme="light"] .parent-dashboard-card .card-header {
    background-color: #f8f9fa !important;
    border-bottom-color: #dee2e6 !important;
    color: #212529 !important;
}

html[data-bs-theme="dark"] .parent-dashboard-card .card-body {
    background-color: #495057 !important;
    color: #e9ecef !important;
}

html[data-bs-theme="light"] .parent-dashboard-card .card-body {
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* Child selection cards within parent dashboard */
html[data-bs-theme="dark"] .parent-dashboard-card .child-selection-card {
    background-color: #3a424a !important;
    border: 1px solid #6c757d !important;
    color: #e9ecef !important;
}

html[data-bs-theme="light"] .parent-dashboard-card .child-selection-card {
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    color: #212529 !important;
}

/* Child age text - theme aware */
html[data-bs-theme="dark"] .parent-dashboard-card .child-age {
    color: #e9ecef !important;
}

html[data-bs-theme="light"] .parent-dashboard-card .child-age {
    color: #6c757d !important;
}

/* Schedule form container styling - theme aware */
html[data-bs-theme="dark"] .schedule-form-container {
    background-color: #495057;
    border-color: #6c757d;
    color: #e9ecef;
}

html[data-bs-theme="light"] .schedule-form-container {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #212529;
}

.ack-body {
    padding: 0.75rem 1rem;
}
html[data-bs-theme="dark"] .ack-body {
    background: #1e293b;
    color: #e2e8f0;
}
html[data-bs-theme="light"] .ack-body {
    background: #ffffff;
    color: #212529;
}

.ack-form {
    padding: 1rem;
}
html[data-bs-theme="dark"] .ack-form {
    background: #1e293b;
}
html[data-bs-theme="light"] .ack-form {
    background: #ffffff;
}

.ack-detail {
    margin-bottom: 0.5rem;
}
html[data-bs-theme="dark"] .ack-detail {
    color: #e2e8f0;
}
html[data-bs-theme="light"] .ack-detail {
    color: #212529;
}

.ack-badge {
    background: #374151;
    color: #d1d5db;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.ack-field {
    margin-bottom: 1rem;
}

.ack-label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}
html[data-bs-theme="dark"] .ack-label {
    color: #f1f5f9;
}
html[data-bs-theme="light"] .ack-label {
    color: #212529;
}

.ack-input {
    width: 100%;
    padding: 0.5rem;
    border-radius: 0.375rem;
}
html[data-bs-theme="dark"] .ack-input {
    border: 1px solid #475569;
    background: #1e293b;
    color: #f1f5f9;
}
html[data-bs-theme="light"] .ack-input {
    border: 1px solid #ced4da;
    background: #ffffff;
    color: #212529;
}

.ack-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ack-help {
    margin-top: 0.25rem;
    font-size: 0.875rem;
}
html[data-bs-theme="dark"] .ack-help {
    color: #94a3b8;
}
html[data-bs-theme="light"] .ack-help {
    color: #6c757d;
}

.ack-warning {
    background: #fef3c7 !important;
    color: #92400e !important;
    padding: 1rem !important;
    border-radius: 0.375rem !important;
    margin-bottom: 1rem !important;
    border: 1px solid #f59e0b !important;
}

.ack-warning h6 {
    margin: 0 0 0.5rem 0;
    color: #92400e;
}

.ack-warning p {
    margin: 0;
}

.ack-buttons {
    display: flex;
    gap: 0.5rem;
}

.ack-btn {
    padding: 0.5rem 1rem !important;
    border: none !important;
    border-radius: 0.375rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    text-decoration: none !important;
    display: inline-block !important;
}

.ack-btn-primary {
    background: #198754 !important;
    color: white !important;
    border: 1px solid #198754 !important;
}

.ack-btn-primary:hover,
.ack-btn-primary:focus,
.ack-btn-primary:active {
    background: #146c43 !important;
    color: white !important;
    border: 1px solid #146c43 !important;
}

.ack-btn-secondary {
    background: #ffc107 !important;
    color: #212529 !important;
    border: 1px solid #ffc107 !important;
}

.ack-btn-secondary:hover,
.ack-btn-secondary:focus,
.ack-btn-secondary:active {
    background: #e0a800 !important;
    color: #212529 !important;
    border: 1px solid #e0a800 !important;
}

/* Custom styles for Provider2Parent chat */

/* Message bubbles */
.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.message-sent {
    background-color: var(--bs-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-received {
    border-bottom-left-radius: 4px;
}

/* Theme-aware message bubble styling */
html[data-bs-theme="dark"] .message-received {
    background-color: #495057;
    color: #e9ecef;
}

html[data-bs-theme="light"] .message-received {
    background-color: #e9ecef;
    color: #212529;
}

.message-header {
    font-size: 0.85rem;
    margin-bottom: 4px;
}

/* Theme-aware message header styling */
html[data-bs-theme="dark"] .message-header {
    opacity: 0.9;
    color: #cbd5e1;
}

html[data-bs-theme="light"] .message-header {
    opacity: 0.8;
    color: #64748b;
}

.message-content {
    margin: 8px 0;
    line-height: 1.4;
}

.message-attachment {
    margin-top: 8px;
    padding: 8px;
    border-radius: 8px;
}

/* Theme-aware attachment styling */
html[data-bs-theme="dark"] .message-attachment {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

html[data-bs-theme="light"] .message-attachment {
    background-color: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.attachment-info {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.attachment-name {
    font-weight: 500;
    word-break: break-all;
}

/* Better filename text handling */
.filename-text {
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    max-width: calc(100% - 120px); /* Leave space for icons and buttons */
    line-height: 1.3;
}

/* Mobile save notice styling */
.mobile-save-notice {
    display: none; /* Hidden by default, shown via JavaScript on mobile */
    padding: 8px 12px;
    background-color: rgba(255, 193, 7, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--bs-warning);
}

/* Image preview enhancements */
.image-preview {
    position: relative;
}

.image-preview img {
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease;
}

.image-preview img:hover {
    transform: scale(1.02);
    cursor: pointer;
}

/* Image preview responsiveness */
.image-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Mobile image fix - Force visibility with better compatibility */
.mobile-image {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 90vw !important;
    max-height: 300px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    border: 2px solid #007bff !important; /* Debug border for mobile */
    background-color: #f8f9fa !important; /* Debug background */
}

/* Force mobile image containers to be visible */
@media (max-width: 768px) {
    .image-preview {
        display: block !important;
        background: #e3f2fd !important; /* Debug background for container */
        padding: 10px !important;
        border: 1px dashed #2196f3 !important; /* Debug border for container */
        min-height: 50px !important;
    }
}

@media (max-width: 768px) {
    .message-bubble {
        max-width: 90%;
    }
    
    .message-attachment {
        margin: 4px 0;
        padding: 6px;
    }
}

/* Chat container scroll */
#chat-container {
    scrollbar-width: thin;
    scrollbar-color: var(--bs-secondary) transparent;
}

#chat-container::-webkit-scrollbar {
    width: 6px;
}

#chat-container::-webkit-scrollbar-track {
    background: transparent;
}

#chat-container::-webkit-scrollbar-thumb {
    background-color: var(--bs-secondary);
    border-radius: 3px;
}

/* Form enhancements */
#message-input {
    resize: none;
    border-radius: 12px;
}

#message-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

.btn {
    border-radius: 12px;
}

/* File input styling */
#file-input {
    border-radius: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 85%;
    }
    
    /* Default card body height for chat screens */
    .card-body {
        height: 400px !important;
    }
    
    /* Allow incident report forms to expand */
    .incident-form .card-body {
        height: auto !important;
        min-height: 400px;
    }
}

/* Animation for new messages */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    animation: fadeInUp 0.3s ease-out;
}

/* User type indicators */
.fa-user {
    color: var(--bs-info);
}

.fa-user-tie {
    color: var(--bs-warning);
}

/* Better file type icons */
.fa-file-pdf {
    color: #dc3545;
}

.fa-file-word {
    color: #2b579a;
}

.fa-image {
    color: #28a745;
}

.fa-file-alt {
    color: var(--bs-info);
}

/* Image preview styling */
.image-preview img {
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.image-preview img:hover {
    border-color: var(--bs-primary);
    transform: scale(1.02);
}

/* Child selector styling - theme aware */
#child-select {
    border-radius: 8px;
    border: 1px solid var(--bs-border-color);
}

html[data-bs-theme="dark"] #child-select {
    background-color: #495057;
    color: #e9ecef;
    border-color: #6c757d;
}

html[data-bs-theme="light"] #child-select {
    background-color: #ffffff;
    color: #212529;
    border-color: #ced4da;
}

/* Child profile header styling */
.fa-child {
    color: var(--bs-success);
}

/* Modal image styling */
#modalImage {
    max-height: 80vh;
    border-radius: 8px;
}

/* Child profile sidebar styling */
.card-body .mb-3:last-child {
    margin-bottom: 0 !important;
}

.card-body .form-label.fw-bold {
    color: var(--bs-primary);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.card-body .form-control-sm {
    font-size: 0.8rem;
}

.card-body strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.card-body p.small {
    font-size: 0.8rem;
    line-height: 1.3;
}

/* Responsive adjustments for sidebar */
@media (max-width: 991px) {
    .col-lg-3.col-xl-3 {
        margin-bottom: 1rem;
    }
}

/* User type specific colors */
.text-danger {
    font-weight: 600;
}

.text-warning {
    font-weight: 600;
}

.text-info {
    font-weight: 600;
}

/* Add child form styling */
.form-label.fw-bold {
    color: var(--bs-primary);
    font-size: 0.9rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--bs-secondary);
}

.alert-info {
    background-color: rgba(13, 202, 240, 0.1);
    border-color: rgba(13, 202, 240, 0.2);
}

/* Button spacing */
.btn + .btn {
    margin-left: 0.5rem;
}
