/* ==========================================================================
   Base Colors & Typography matching your design theme
   ========================================================================== */
body {
    font-family: Arial, sans-serif;
    margin: 40px;
    background-color: #f4f6f9;
    color: #333;
    display: flex; 
    justify-content: center;
    align-items: center;
}

h1, h2, h3, .section-title {
    color: #d9534f;
}

.section-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 30px 0 15px 0;
}

/* ==========================================================================
   Layout Structure Blocks
   ========================================================================== */
.page-container {
    margin-top: 75px;
    padding-bottom: 80px;
    box-sizing: border-box;
    max-width: 1100px;
}

.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
}

@media (max-width: 1100px) {
    .grid-2-col {
        grid-template-columns: 1fr;
    }
}

/* Base Card Container */
.card {
    background: #fff;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Stats Panel
   ========================================================================== */
.stats-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.stat-card {
    background: #fff;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 200px;
    border-left: 4px solid #666;
}

.stat-card.critical {
    border-left-color: #d9534f;
    background-color: #fff9f9;
}

.stat-card h4 {
    margin: 0 0 5px 0;
    color: #666;
    font-size: 0.9em;
    text-transform: uppercase;
}

.stat-card .value {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
}

.stat-card.critical .value {
    color: #d9534f;
}

/* ==========================================================================
   Resident Encapsulation Containers
   ========================================================================== */
.resident-group-card {
    background: #fff;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #d9534f;
}

.resident-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.resident-header h3 {
    margin: 0;
    font-size: 1.3em;
    color: #333;
}

.resident-header p {
    margin: 3px 0;
    color: #555;
    font-size: 0.9em;
}

.nested-meds-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #555;
    font-size: 14px;
}

/* ==========================================================================
   Tables Design Template
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    font-size: 0.95em;
    vertical-align: middle;
}

th {
    background-color: #d9534f;
    color: white;
}

.low-stock-row {
    background-color: #fff4f4;
}

/* ==========================================================================
   Form Inputs & Elements Styles
   ========================================================================== */
.inline-input {
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    box-sizing: border-box;
}

.rx-tag {
    background-color: #eef2f7;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

/* Custom layout for check boxes grids */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 4px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: normal !important;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto !important;
}

.form-section {
    background: #fdfdfd;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 20px;
}

.form-section h3 {
    margin-top: 0;
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

/* ==========================================================================
   Badge and Buttons Actions Layout
   ========================================================================== */
.alert-badge {
    background-color: #d9534f;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85em;
    display: inline-block;
}

.btn-edit, .btn-save, .btn-remove {
    cursor: pointer;
    font-weight: bold;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.btn-edit {
    background: transparent;
    color: #0275d8;
    border: 1px solid #0275d8;
    padding: 4px 10px;
    font-size: 0.85em;
    text-decoration: none;
    display: inline-block;
}

.btn-save {
    background-color: #d9534f;
    color: white;
    border: 1px solid #d9534f;
    padding: 8px 16px;
    font-size: 0.95em;
}

.btn-edit:hover {
    background-color: #e6f2ff;
}

.btn-save:hover {
    background-color: #c9302c;
}

/* ==========================================================================
   Unified Popup Overlay Modal Box Styles
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    overflow-y: auto;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 25px;
    border-radius: 4px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.close {
    float: right;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
}

.form-section-title {
    font-weight: bold;
    color: #d9534f;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 4px;
    margin: 18px 0 10px 0;
    text-transform: uppercase;
    font-size: 0.85em;
}

/* ==========================================================================
   Alert Banners & Sub-elements
   ========================================================================== */
.alert-banner {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-weight: bold;
}

.alert-banner.success {
    background-color: #d4edda;
    color: #155724;
    border-left: 5px solid #28a745;
}

.alert-banner.error {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 5px solid #dc3545;
}

.time-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.time-row input[type="time"] {
    width: auto;
}

.btn-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove:hover {
    background: #bd2130;
}

/* Container layout styling */
.print-btn-container { 
    margin: 30px 0; 
    text-align: center; 
}

/* Print Button styling */
.btn-print {
    background-color: #a0241c;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 15px;
    font-weight: bold;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Hover effect */
.btn-print:hover {
    background-color: #a0241c;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

/* Click/Active effect */
.btn-print:active {
    background-color: #a0241c;
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Focus indicator for accessibility */
.btn-print:focus-visible {
    outline: 3px solid #80bdff;
    outline-offset: 2px;
}

/* Hide the button completely when printing onto paper */
@media print {
    .print-btn-container,
    .btn-print {
        display: none !important;
    }
}

/* ==========================================================================
   Dedicated Edit Forms Layout Sheet Component (edit_*.php)
   ========================================================================== */

/* Narrower centralized frame layout built for data modification inputs */
.edit-form-frame {
    width: 100%;
    max-width: 580px;
    margin: 30px auto;
}

/* Informational subtitles situated directly under headers */
.edit-sub-description {
    color: #666;
    font-size: 0.95rem;
    margin-top: -10px;
    margin-bottom: 25px;
    line-height: 1.4;
}

/* Two-column layout grid for split inputs like First and Last name fields */
.form-input-split-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* Ensures custom full-width inputs look uniform and consistent inside forms */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    background-color: #ffffff;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Light up borders with a subtle blue ring effect during active user typing focus */
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #0275d8;
    box-shadow: 0 0 0 3px rgba(2, 117, 216, 0.15);
}

/* Standard structural block layout configuration for page actions row */
.edit-actions-panel {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* Styled gray secondary utility exit button framework */
.btn-edit-cancel {
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 4px;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-edit-cancel:hover {
    background-color: #dee2e6;
    color: #212529;
}

/* Inline Destructive Warning Panel Partition wrapper */
.destructive-delete-zone {
    margin-top: 35px;
    padding-top: 20px;
    border-top: 2px dashed #dc3545;
}

.destructive-delete-zone h4 {
    margin: 0 0 8px 0;
    color: #c9302c;
    font-size: 1rem;
    text-transform: uppercase;
    font-weight: bold;
}

.destructive-delete-zone p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 0.88rem;
    line-height: 1.4;
}

/* Styled dangerous, highly visual error fallback delete button template */
.btn-destructive-action {
    background-color: #ffffff;
    color: #dc3545;
    border: 1px solid #dc3545;
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-destructive-action:hover {
    background-color: #dc3545;
    color: #ffffff;
}

/* Responsive breakpoint rules to collapse split grids to stacked on tiny views */
@media (max-width: 540px) {
    .form-input-split-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .edit-actions-panel {
        flex-direction: column-reverse;
    }
    .btn-edit-cancel,
    .btn-dashboard-save {
        width: 100%;
    }
}
