/* CRITICAL: Fix transparent WebView during page transitions */
html,
body {
    background-color: #ffffff;
    background: #ffffff;
    color: var(--color-text);
}

/* Force all pages to have solid background */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Ensure containers are opaque - specific selectors only */
.container {
    background-color: #ffffff;
}

.page-content {
    background-color: #ffffff;
}

/* AJAX Navigation - Smooth content transitions */
#main-content {
    background-color: #ffffff;
    min-height: 100vh;
    transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* AJAX transition overlay - blocks interaction during page transitions */
.ajax-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    z-index: 9998;
    pointer-events: none;
}

.ajax-transition-overlay.active {
    pointer-events: all;
}

/* Prevent scrollbar shift on content change */
html {
    overflow-y: scroll;
}

/* Center all page headers globally */
.page-title {
    text-align: center;
}

.page-title h2,
.page-title h1 {
    margin-left: auto;
    margin-right: auto;
}

/* Ensure page content centers properly */
.page-content {
    width: 100%;
}

/* Center direct h1/h2 children in page content (applies to all pages) */
.page-content > h1,
.page-content > h2 {
    text-align: center;
}

/* Force Light Mode - Override System Preferences */
:root {
    color-scheme: light;
}

html {
    color-scheme: light;
}

body {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Override any dark mode preferences */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: light !important;
    }
    
    html, body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    
    /* Force light color scheme on key elements for better performance */
    :root, body, .page-card, .content-card {
        color-scheme: light !important;
    }
}

/* Base Styles - Mobile First */
* {
    box-sizing: border-box;
}

:root {
    /* Primary Colors */
    --color-primary: #5b21b6; /* Dark Purple */
    --color-primary-hover: #4c1d95;
    --color-success: #28a745;
    --color-success-hover: #218838;
    --color-danger: #dc3545;
    --color-danger-hover: #c82333;
    --color-warning: #ffc107;
    --color-warning-hover: #e0a800;
    --color-info: #007bff;
    --color-info-hover: #0056b3;
    --color-secondary: #6c757d;
    --color-secondary-hover: #545b62;
    
    /* Text Colors - WCAG AA Compliant for Light Backgrounds */
    --color-text: #333; /* Primary text - Contrast ratio 12.6:1 on white */
    --color-text-primary: #333; /* Primary text - Contrast ratio 12.6:1 on white */
    --color-text-secondary: #666; /* Secondary text - Contrast ratio 5.7:1 on white (WCAG AA) */
    
    /* Background & Border Colors */
    --color-border: #ddd;
    --color-bg-light: #f5f5f5;
    --color-bg-gray: #f8f9fa;
    --color-bg-white: #fff;
    
    /* Shadows & Borders */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --transition: all 0.3s ease;
}

/* DARK MODE TEMPORARILY DISABLED - 2026-02-06
 * Current implementation does not properly change text colors
 * Causes dark text on dark backgrounds, making app unusable
 * TODO: Implement complete dark mode color scheme with proper contrast
 *
 * Light mode - explicit
 * body.theme-light {
 *     --color-text: #333;
 *     --color-text-primary: #333;
 *     --color-text-secondary: #666;
 *     --color-border: #ddd;
 *     --color-bg-light: #f5f5f5;
 *     --color-bg-gray: #f8f9fa;
 *     --color-bg-white: #fff;
 *     --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
 *     --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.1);
 *     --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
 * }
 *
 * Dark mode - explicit
 * body.theme-dark {
 *     --color-text: #e0e0e0;
 *     --color-text-primary: #f5f5f5;
 *     --color-text-secondary: #b0b0b0;
 *     --color-border: #444;
 *     --color-bg-light: #1a1a1a;
 *     --color-bg-gray: #2a2a2a;
 *     --color-bg-white: #1e1e1e;
 *     --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
 *     --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
 *     --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
 * }
 *
 * Device mode - follows system preference
 * @media (prefers-color-scheme: dark) {
 *     body:not(.theme-light):not(.theme-dark) {
 *         --color-text: #e0e0e0;
 *         --color-text-primary: #f5f5f5;
 *         --color-text-secondary: #b0b0b0;
 *         --color-border: #444;
 *         --color-bg-light: #1a1a1a;
 *         --color-bg-gray: #2a2a2a;
 *         --color-bg-white: #1e1e1e;
 *         --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
 *         --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
 *         --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
 *     }
 * }
 */

body {
    padding-bottom: 100px; /* Account for fixed footer */
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background-color: #ffffff !important; /* Force white background to prevent black flash */
    font-size: 16px;
    line-height: 1.6;
    color: #333 !important; /* Force dark text */
}

/* Card Layout (for all pages) */
.page-card, .content-card {
    background: var(--color-bg-white);
    background-color: #fff !important; /* Force white background */
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 600px;
    margin: 16px auto;
}

.centered-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

/* Headers - Dark Purple Theme */
.page-header, .card-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--color-primary);
}

.page-header h2, .card-header h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    color: var(--color-primary);
    font-weight: 600;
}

.page-header p, .card-header p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* Section Headers */
.section-header {
    background: var(--color-primary);
    color: var(--color-bg-white);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 24px 0 16px 0;
    font-weight: 600;
    font-size: 16px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

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

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

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text-primary);
    font-size: 14px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--color-bg-white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.1);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-primary);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-primary);
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: var(--color-bg-white);
}

.radio-label:hover {
    background: var(--color-bg-gray);
}

.radio-label input[type="radio"] {
    margin-right: 10px;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
}

.help-text {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 4px;
    margin-bottom: 0;
    line-height: 1.4;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--color-bg-white);
    color: var(--color-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.form-actions .btn {
    flex: 1;
}

/* Form Grid - For multi-column forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .form-grid .form-group-full {
        grid-column: 1 / -1;
    }
}

/* Buttons - Mobile Optimized - Solidified Styles */
.btn {
    padding: 14px 20px;
    border-radius: 6px;
    border: none;
    font-size: 16px;
    color: #ffffff;
    width: 100%;
    display: block;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    text-decoration: none;
    font-weight: 500;
    min-height: 48px;
    line-height: 1.2;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-accept { 
    background: #28a745; 
    color: #ffffff;
}
.btn-accept:hover { 
    background: #218838; 
}

.btn-deny { 
    background: #dc3545; 
    color: #ffffff;
}
.btn-deny:hover { 
    background: #c82333; 
}

.btn-info { 
    background: #007bff; 
    color: #ffffff;
}
.btn-info:hover { 
    background: #0056b3; 
}

.btn-primary { 
    background: #2563eb; 
    color: #ffffff;
}
.btn-primary:hover { 
    background: #1d4ed8; 
}

.btn-secondary { 
    background: #6c757d; 
    color: #ffffff;
}
.btn-secondary:hover { 
    background: #545b62; 
}

.btn-danger { 
    background: #dc3545; 
    color: #ffffff;
}
.btn-danger:hover { 
    background: #c82333; 
}

/* Dashboard grid - Mobile First (2 columns on mobile, 3 on desktop) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

@media (min-width: 576px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

/* Colorful Tile Cards - Solidified */
.tile {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: #ffffff;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0);
    transition: var(--transition);
}

.tile:hover::before {
    background: rgba(255, 255, 255, 0.1);
}

.tile:hover {
    box-shadow: var(--shadow-lg);
}

.tile .tile-icon {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    color: #ffffff;
}

.tile .tile-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

.tile .tile-desc {
    font-size: 13px;
    opacity: 0.9;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

/* Tile color variations */
.tile-purple { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
}
.tile-blue { 
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); 
}
.tile-green { 
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%); 
}
.tile-orange { 
    background: linear-gradient(135deg, #f77062 0%, #fe5196 100%); 
}
.tile-teal { 
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); 
}
.tile-red { 
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); 
}

/* Hamburger menu - Improved for mobile */
.hamburger {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    z-index: 1000;
    padding: 8px;
    background: var(--color-bg-white);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.hamburger:hover {
    background: var(--color-primary);
}

.hamburger:hover div {
    background: var(--color-bg-white);
}

.hamburger div {
    width: 100%;
    height: 3px;
    background: var(--color-primary);
    margin: 5px 0;
    border-radius: 2px;
    transition: var(--transition);
}

/* Dropdown menu - expands downward */
.menu {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 260px;
    background: var(--color-bg-white);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 12px;
    z-index: 999;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.menu.open {
    max-height: 80vh;
    overflow-y: auto;
    opacity: 1;
    padding: 16px;
}

.menu h3 {
    margin: 0 0 12px 0;
    color: var(--color-primary);
    font-size: 18px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--color-primary);
}

.menu a {
    display: block;
    padding: 12px 16px;
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 4px;
    font-weight: 500;
}

.menu a:hover {
    background: var(--color-primary);
    color: var(--color-bg-white);
    transform: translateX(4px);
}

/* Page Footer */
.page-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.page-footer p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 14px;
}

.page-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.page-footer a:hover {
    text-decoration: underline;
}

/* Autocomplete Results */
.autocomplete-results {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

/* Profile Picture */
.profile-picture {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 20px;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.profile-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #ddd;
    margin: 0 auto 20px;
    display: block;
}

/* Info Display */
.info-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

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

.info-label {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.info-value {
    color: #666;
}

/* Checkbox List */
.checkbox-group {
    margin-bottom: 20px;
}

.checkbox-group label {
    display: block;
    padding: 10px 0;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
}

/* Responsive Typography */
@media (min-width: 768px) {
    .page-header h2, .card-header h2 {
        font-size: 28px;
    }
    
    .page-card, .content-card {
        padding: 40px;
    }
}

/* Touch-friendly inputs on mobile */
@media (max-width: 767px) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--color-bg-light);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--color-bg-white);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast-error {
    border-left: 4px solid var(--color-danger);
}

.toast-info {
    border-left: 4px solid var(--color-info);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Day of Week Visualizer */
.day-visualizer {
    display: flex;
    gap: 8px;
    justify-content: space-around;
    margin: 16px 0;
    flex-wrap: wrap;
}

.day-badge {
    flex: 1;
    min-width: 40px;
    padding: 8px;
    text-align: center;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    background: #e0e0e0;
    color: #4a4a4a;
    transition: var(--transition);
    border: 1px solid #ccc;
}

.day-badge.active {
    background: var(--color-primary);
    color: var(--color-bg-white);
    transform: scale(1.05);
}

/* Schedule Display */
.schedule-grid {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.schedule-time {
    background: var(--color-bg-light);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--color-primary);
}

.schedule-time-label {
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 8px;
    font-size: 16px;
}

.schedule-time-value {
    color: var(--color-text-primary);
    font-size: 14px;
}

.schedule-instructions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* Medication Cards */
.medication-card {
    background: var(--color-bg-white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
    border-left: 4px solid var(--color-primary);
}

.medication-card:hover {
    box-shadow: var(--shadow-lg);
}

.medication-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.medication-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-primary);
    margin: 0;
}

.medication-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.medication-status.active {
    background: #d4edda;
    color: #155724;
}

.medication-status.archived {
    background: #f8d7da;
    color: #721c24;
}

/* NHS Alert Display */
.nhs-alert {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 16px 0;
}

.nhs-alert-title {
    font-weight: 600;
    color: #856404;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nhs-alert-title::before {
    content: '⚠️';
    font-size: 20px;
}

.nhs-alert-body {
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
}

/* Action Button Group */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

@media (min-width: 576px) {
    .action-buttons {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 768px) {
    .action-buttons.three-col {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Day Toggle Buttons for Medication Schedule */
.day-toggle-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.day-toggle input[type="checkbox"] {
    display: none;
}

.day-toggle-btn {
    display: inline-block;
    padding: 10px 16px;
    border: 2px solid var(--color-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.day-toggle input[type="checkbox"]:checked + .day-toggle-btn {
    background: var(--color-primary);
    color: white;
}

/* Medication Schedule Display on Tiles */
.tile-schedule {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 4px;
}

/* Success/Confirmation Modal */
.success-modal,
.error-modal,
.confirmation-modal,
.info-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background: var(--color-bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 400px;
    width: 90%;
}

.success-modal.show,
.error-modal.show,
.confirmation-modal.show,
.info-modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.success-modal-body,
.error-modal-body,
.confirmation-modal-body,
.info-modal-body {
    padding: 32px 24px 0 24px;
    text-align: center;
}

.success-modal .modal-icon,
.error-modal .modal-icon,
.confirmation-modal .modal-icon,
.info-modal .modal-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
}

.success-modal .modal-icon,
.confirmation-modal .modal-icon {
    background: #d4edda;
    color: #28a745;
}

.error-modal .modal-icon {
    background: #f8d7da;
    color: #dc3545;
}

.info-modal .modal-icon {
    background: #d1ecf1;
    color: #007bff;
}

.success-modal .modal-message,
.error-modal .modal-message,
.confirmation-modal .modal-message,
.info-modal .modal-message {
    font-size: 18px;
    color: var(--color-text-primary);
    margin-bottom: 24px;
    font-weight: 500;
}

.success-modal .modal-countdown-bar,
.error-modal .modal-countdown-bar,
.confirmation-modal .modal-countdown-bar,
.info-modal .modal-countdown-bar {
    width: 100%;
    height: 4px;
    background: var(--color-bg-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
}

.countdown-fill {
    height: 100%;
    width: 100%;
    transform-origin: left;
}

.success-modal .countdown-fill,
.confirmation-modal .countdown-fill {
    background: var(--color-success);
}

.error-modal .countdown-fill {
    background: var(--color-danger);
}

.info-modal .countdown-fill {
    background: var(--color-info);
}

@keyframes countdown {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

/* Expandable Section for Archived Medications */
.expandable-section {
    margin-top: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.section-header-toggle {
    background: var(--color-bg-light);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
    color: var(--color-text-primary);
    transition: var(--transition);
    user-select: none;
}

.section-header-toggle:hover {
    background: var(--color-border);
}

.toggle-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.toggle-icon.expanded {
    transform: rotate(90deg);
}

.expandable-section.expanded .toggle-icon {
    transform: rotate(90deg);
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.expandable-section.expanded .section-content {
    max-height: 5000px;
}

/* Full-width medication tiles */
.medication-tile-fullwidth {
    background: #e8f5e9;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    text-decoration: none;
    display: block;
    border-left: 4px solid #66bb6a;
}

.medication-tile-fullwidth:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.medication-tile-line1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.medication-tile-line2 {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.medication-tile-line3 {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* Schedule date styling */
.schedule-date {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-top: -8px;
    margin-bottom: 16px;
}

/* Back to dashboard button */
.back-to-dashboard {
    position: fixed;
    top: 16px;
    left: 16px;
    padding: 10px 16px;
    background: var(--color-bg-white);
    color: var(--color-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 4px;
}

.back-to-dashboard:hover {
    background: var(--color-primary);
    color: var(--color-bg-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Expandable menu sections */
.menu-section {
    margin-bottom: 4px;
}

.menu-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
}

.menu-section-header:hover {
    background: var(--color-primary);
    color: var(--color-bg-white);
}

.menu-section-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 20px;
    border-left: 2px solid var(--color-primary);
    margin-left: 16px;
}

.menu-section-children.expanded {
    max-height: 500px;
}

.menu-section-children a {
    display: block;
    padding: 8px 16px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.menu-section-children a:hover {
    background: var(--color-bg-light);
    color: var(--color-primary);
}

.menu-toggle-icon {
    font-size: 12px;
    transition: transform 0.3s ease;
}

/* Nested menu sections (Admin Panel inside Settings) */
.menu-section.nested {
    margin-left: 0;
    padding-left: 0;
    margin-bottom: 4px;
}

.menu-section-header.nested-header {
    padding: 8px 16px;
    font-size: 14px;
}

/* Time group styling for dashboard */
.time-group {
    margin-bottom: 24px;
}

.time-group-header {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-group-medications {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Button Loading Spinner */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Form submission protection */
form[data-submitting="true"] button[type="submit"],
form[data-submitting="true"] input[type="submit"] {
    opacity: 0.6;
    cursor: not-allowed;
}

button[disabled], input[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Medication Icon and Color Selector */
.icon-selector, .color-selector {
    margin-bottom: 24px;
}

.icon-selector label, .color-selector label {
    display: block;
    margin-bottom: 12px;
    color: var(--color-text-primary);
    font-size: 14px;
    font-weight: 500;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: var(--color-bg-white);
}

.icon-option svg {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
}

/* Icon selector grid - white fill with black stroke for visibility */
.icon-grid .icon-option svg path,
.icon-grid .icon-option svg circle,
.icon-grid .icon-option svg ellipse,
.icon-grid .icon-option svg rect {
    fill: white !important;
    stroke: black !important;
    stroke-width: 1 !important;
}

/* Secondary color paths in icon selector should also be white */
.icon-grid .icon-option svg path.secondary-color {
    fill: white !important;
    stroke: black !important;
    stroke-width: 1 !important;
    opacity: 0.7 !important;
}

/* Lines in scored tablets should remain visible */
.icon-grid .icon-option svg line {
    stroke: #666 !important;
    stroke-width: 1 !important;
}

.icon-option .icon-name {
    font-size: 10px;
    text-align: center;
    color: var(--color-text-secondary);
}

.icon-option:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-light);
}

.icon-option.selected {
    border-color: var(--color-primary);
    background: rgba(91, 33, 182, 0.1);
}

.color-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--color-text-primary);
    box-shadow: 0 0 0 2px var(--color-bg-white);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

/* Secondary color options have same styling as primary */
.secondary-color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
    position: relative;
}

.secondary-color-option:hover {
    transform: scale(1.1);
}

.secondary-color-option.selected {
    border-color: var(--color-text-primary);
    box-shadow: 0 0 0 2px var(--color-bg-white);
}

.secondary-color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.color-selector {
    margin-bottom: 20px;
}

.color-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.icon-selector {
    margin-bottom: 20px;
}

.icon-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--color-text-primary);
}

#icon_preview {
    margin-top: 20px;
    padding: 20px;
    text-align: center;
    background: var(--color-bg-light);
    border-radius: var(--radius-md);
    border: 2px dashed var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.med-icon svg {
    width: 100%;
    height: 100%;
}

/* Color Picker Modal Styles */
.color-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.color-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.color-modal-content {
    position: relative;
    background: var(--color-bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.color-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 2px solid var(--color-primary);
    background: var(--color-bg-light);
}

.color-modal-header h3 {
    margin: 0;
    color: var(--color-primary);
    font-size: 22px;
    font-weight: 600;
}

.color-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.color-modal-close:hover {
    background: var(--color-danger);
    color: white;
}

.color-modal-body {
    padding: 24px;
}

.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 600px) {
    .color-palette-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }
}

@media (max-width: 400px) {
    .color-palette-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
}

.color-palette-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
    position: relative;
    min-height: 50px;
}

.color-palette-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-palette-option.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-bg-white), 0 0 0 4px var(--color-primary);
}

.color-palette-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 0, 0, 0.5);
}

.color-hex-input-group {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.color-hex-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--color-text-primary);
}

#color-hex-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: monospace;
    text-transform: uppercase;
}

#color-hex-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.color-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-light);
}

.color-modal-footer .btn {
    flex: 1;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
}

/* Custom color button styling */
.custom-color-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--color-bg-gray);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-top: 12px;
}

.custom-color-btn:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    border-style: solid;
}

.custom-color-btn::before {
    content: '🎨 ';
}

/* Icon toggle button */
.btn-toggle-icons {
    background: var(--color-bg-gray);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    color: var(--color-text-primary);
}

.btn-toggle-icons:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Selected icon display */
#selected-icon-display {
    font-size: 14px;
}

#selected-icon-display strong {
    color: var(--color-primary);
}

#selected-icon-name {
    color: var(--color-text-primary);
    font-weight: 500;
}






/* Custom Modal Styles */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.custom-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-modal-header h3 {
    margin: 0 0 16px 0;
    color: var(--color-primary);
    font-size: 20px;
}

.custom-modal-body {
    margin-bottom: 24px;
    color: var(--color-text);
    line-height: 1.5;
}

.custom-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
