.medication-grid {
    gap: 0 !important;
}
.medication-card {
    margin: 0 !important;
    padding-bottom: 0 !important;
}
/* Ensure no line-through on medication dosage */
.medication-dosage {
    text-decoration: none !important;
}
/* Main Styles - Core application styling */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for better mobile support */
    padding: 20px;
    /* Use CSS custom property for dynamic height */
    min-height: var(--vh, 100vh);
}

.container {
    max-width: 1200px;
    margin: 60px auto 0; /* Increased top margin to make room for the language selector */
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: visible; /* Allow dropdowns to escape */
    position: relative; /* Added to establish a positioning context */
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Form Styles */
.add-medication {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

/* Force the primary medication entry row to stay on one line */
.form-row.medication-primary-row {
    grid-template-columns:
        minmax(180px, 1fr)
        90px
        120px
        150px
        150px;
    overflow-x: auto;
    overflow-y: visible !important; /* Allow dropdown to show */
}

.form-row.medication-primary-row #strength {
    min-width: 90px !important;
}

.form-row.medication-primary-row .lookup-btn {
    min-width: 90px !important;
    margin-left: 0;
    margin-top: 28px;
}

/* Force the secondary refill row to stay on one line */
.form-row.medication-secondary-row {
    grid-template-columns:
        minmax(200px, 1fr)
        minmax(180px, 1fr)
        minmax(180px, 1fr)
        minmax(180px, 1fr);
    overflow-x: auto;
}

.form-row.medication-secondary-row .form-group input,
.form-row.medication-secondary-row .form-group select {
    width: 100% !important;
}

.form-row.medication-primary-row .form-group input,
.form-row.medication-primary-row .form-group select,
.form-row.medication-primary-row .form-group button {
    width: 100% !important;
}

.form-group {
    display: flex;
    flex-direction: column;
}

/* Ensure medication name group can show dropdown */
#medicationNameGroup {
    position: relative !important;
    overflow: visible !important;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #495057;
}

.required::after {
    content: " *";
    color: #e53935;
}

.form-group input, .form-group textarea, .form-group select {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    background: white;
    width: 35%;
    color: #222;
    font-weight: bold;
    font-size: 14px;
}

/* Button Styles */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: rgb(47, 41, 41);
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Add Medication Button */
.add-medication-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

.add-medication-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.add-medication-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.export-btn, .import-btn {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.export-btn:hover, .import-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.lookup-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lookup-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.4);
}

.lookup-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 15px;
    transition: background-color 0.2s ease;
}

.delete-btn:hover {
    background: #c82333;
}

/* Export/Import Section */
.export-import-section {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.search-container {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-label {
    color: #2c3e50;
    font-weight: 600;
    font-size: 14px;
}

.search-input {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    width: 200px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.theme-toggle {
    background: none;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.theme-toggle:hover {
    background: #667eea;
    color: white;
}

/* Medication List Styles */
.medication-list {
    padding: 30px;
}

.medication-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.medication-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 50%;
    min-width: 180px;
    max-width: 420px;
    width: min(50%, max-content);
    /* Allow card to grow for long names, but not shrink too small */
    word-break: break-word;
    white-space: normal;
    overflow-wrap: anywhere;
}

.medication-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.medication-card.focused {
    border: 3px solid #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    transform: scale(1.02);
}

.medication-card.highlighted {
    border: 6px solid #000 !important;
    background: #ffff00 !important;
    color: #000 !important;
    font-weight: bold !important;
    box-shadow: 0 0 40px 10px #000 !important;
    outline: 6px solid #fff !important;
    position: relative;
    z-index: 9999 !important;
    transition: background 0.2s, border 0.2s, box-shadow 0.2s;
}
.medication-card.highlighted::before {
    content: "⚡";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 1.1rem;
    color: #000;
    background: #fff;
    border-radius: 50%;
    padding: 1px 4px;
    box-shadow: 0 0 3px #000;
    z-index: 10000;
}

.medication-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
}

.medication-info {
    display: grid;
    gap: 10px;
}

.info-item {
    display: flex;
    align-items: flex-start;
}

.info-label {
    font-weight: 600;
    color: #6c757d;
    min-width: 80px;
    margin-right: 10px;
}

.info-value {
    color: #495057;
    flex: 1;
}

/* Medication Tags */
.dosage {
    background: #e3f2fd;
    color: #1565c0;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none !important;
}

.dosage:hover {
    background: #bbdefb;
}

.dosage-input {
    background: #fff;
    border: 2px solid #1565c0;
    color: #1565c0;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    width: 80px;
}

.dosage-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.2);
}

.amount {
    background: #f3e5f5;
    color: #7b1fa2;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.amount:hover {
    background: #e1bee7;
}

.pill-count {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pill-count:hover {
    background: #c8e6c9;
}

.pill-count-input {
    background: #fff;
    border: 2px solid #2e7d32;
    color: #2e7d32;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    width: 90px;
}

.pill-count-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
}

.medication-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
}

.medication-time:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
}

/* Time Sections */
.time-section {
    margin-bottom: 40px;
}

.time-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: 600;
}

.time-info {
    display: flex;
    align-items: center;
}

.time-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.time-range {
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 0.8;
}

.morning-header {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #e65100;
    border-left: 4px solid #ff9800;
}

.midday-header {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #0277bd;
    border-left: 4px solid #2196f3;
}

.evening-header {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    color: #6a1b9a;
    border-left: 4px solid #9c27b0;
}

.time-icon {
    margin-right: 10px;
    font-size: 1.5rem;
}

.time-count {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Time Input Components */
.time-inputs-container {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.time-input {
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.time-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.medication-name-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    position: relative; /* Add position relative for absolute suggestions */
}

/* Pill Image */
.pill-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    margin-top: 10px;
    display: block;
}

.pill-image-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Statistics */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #667eea;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-label {
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Reminders */
.reminder-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.reminder-text {
    color: #856404;
    font-weight: 500;
    margin-bottom: 10px;
}

.next-dose {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #d4edda;
    padding: 10px 15px;
    border-radius: 6px;
    border-left: 4px solid #28a745;
    margin-bottom: 8px;
}

.current-dose {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff3cd;
    padding: 10px 15px;
    border-radius: 6px;
    border-left: 4px solid #ffc107;
    margin-bottom: 8px;
}

.dose-time {
    font-weight: 600;
    color: #155724;
}

.dose-medication {
    color: #155724;
}

/* Edit Icons */
.edit-icon {
    cursor: pointer;
    opacity: 0.6;
    margin-left: 5px;
    transition: opacity 0.2s ease;
}

.edit-icon:hover {
    opacity: 1;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background-color: #f8f9fa;
    color: #dc3545;
}

.time-inputs-grid {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.time-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-input-group label {
    min-width: 80px;
    font-weight: 600;
    color: #495057;
}

.time-input-group input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.time-input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.time-chip {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.save-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.cancel-btn {
    background: #6c757d;
    color: white;
}

.cancel-btn:hover {
    background: #2e6690;
}

/* Lookup Status */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.lookup-status {
    font-size: 12px;
    margin-top: 5px;
    padding: 5px 10px;
    border-radius: 4px;
}

.lookup-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.lookup-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.lookup-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Notifications */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.notification {
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(400px);
    animation: slideIn 0.3s ease forwards;
}

.notification.error {
    background: #dc3545;
}

.notification.warning {
    background: #ffc107;
    color: #212529;
}

@keyframes slideIn {
    to {
        transform: translateX(0);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #667eea;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Help Modal Content */
.help-content {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.help-list {
    margin-bottom: 20px;
}

.help-content h4 {
    color: #2c3e50;
    margin-top: 15px;
    margin-bottom: 10px;
}

.time-help {
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Medication Suggestions */
.medication-suggestions,
.suggestions-list {
    position: absolute;
    width: 100%;
    max-width: calc(100% - 90px); /* Account for lookup button width */
    max-height: 200px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000; /* Increased z-index */
    margin-top: 5px;
    left: 0;
    top: 100%; /* Position below the input */
    display: none; /* Hidden by default */
}

.suggestions-heading {
    padding: 8px 12px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    background-color: #f5f5f5;
    color: #555;
    font-size: 14px;
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer !important;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
    -webkit-user-select: none; /* Safari */
    user-select: none; /* Prevent text selection */
    font-size: 14px;
    line-height: 1.4;
    border: 2px solid transparent; /* Add visible border */
    margin: 2px 0;
    border-radius: 4px;
    font-weight: 600;
    color: #2c3e50;
}

.suggestion-item:last-child {
    border-bottom: 1px solid #eee;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background-color: #e8f5e9 !important;
    border-color: #28a745 !important;
    outline: 2px solid #28a745;
    outline-offset: -2px;
    transform: translateX(2px);
}

.suggestion-item:active {
    background-color: #d4edda !important;
    transform: translateX(0px);
}

/* Make sure the medication name input container has relative positioning */
.medication-name-row {
    position: relative;
}

/* Ensure medication name input has proper positioning context */
.medication-name-input {
    position: relative;
    z-index: 1;
}

/* Dark theme support */
body.dark-theme .medication-suggestions {
    background-color: #333;
    border-color: #555;
}

body.dark-theme .suggestions-heading {
    background-color: #444;
    color: #ddd;
    border-color: #555;
}

body.dark-theme .suggestion-item {
    border-color: #555;
    color: #eee;
}

body.dark-theme .suggestion-item:hover,
body.dark-theme .suggestion-item:focus {
    background-color: #4a4a4a;
}

/* High contrast theme support */
body.high-contrast .medication-suggestions {
    background-color: #000;
    border: 2px solid #fff;
}

body.high-contrast .suggestions-heading {
    background-color: #000;
    color: #fff;
    border-color: #fff;
}

body.high-contrast .suggestion-item {
    border-color: #fff;
    color: #fff;
}

body.high-contrast .suggestion-item:hover,
body.high-contrast .suggestion-item:focus {
    background-color: #333;
    outline: 2px solid yellow;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    .medication-grid {
        grid-template-columns: 1fr;
    }
    
    /* Mobile button adjustments */
    .btn {
        padding: 14px 20px;
        font-size: 15px;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .add-medication-btn {
        padding: 16px 24px;
        font-size: 16px;
        width: 100%;
        margin-bottom: 12px;
    }
    
    .save-btn, .export-btn, .import-btn {
        padding: 12px 18px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .lookup-btn {
        padding: 8px 12px;
        font-size: 12px;
        margin-left: 8px;
        width: auto;
        min-width: 80px;
    }
    
    .collapse-btn {
        padding: 8px 15px;
        font-size: 14px;
        width: auto;
        margin-bottom: 12px;
    }
    
    /* Modal actions on mobile */
    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-actions button {
        width: 100%;
        margin-bottom: 0;
    }
    
    /* Time period selection adjustments for tablets */
    .time-periods-selection {
        gap: 12px !important;
    }
    
    .time-period-checkbox {
        min-width: 140px !important;
        flex: 1 1 140px !important;
    }
}

/* Portrait orientation specific adjustments */
@media (max-width: 768px) and (orientation: portrait) {
    /* Extra adjustments for portrait mode on phones */
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 6px;
    }
    
    .add-medication-btn {
        padding: 14px 20px;
        font-size: 15px;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .save-btn, .export-btn, .import-btn {
        padding: 10px 16px;
        font-size: 13px;
        width: 100%;
        margin-bottom: 6px;
    }
    
    .time-periods-selection {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .time-period-checkbox {
        min-width: 100% !important;
        flex: 1 1 100% !important;
        margin: 0 0 6px 0 !important;
    }
}

/* Landscape orientation specific adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    /* Ensure app fits screen in landscape mode */
    body {
        padding: 10px !important;
        min-height: var(--vh, 100vh) !important;
    }
    
    .container {
        max-width: none !important;
        margin: 30px auto 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Landscape mode - allow buttons to be more compact since there's more horizontal space */
    .btn {
        width: auto;
        min-width: 120px;
        max-width: 200px;
        margin-bottom: 4px;
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .add-medication-btn {
        width: 100%;
        max-width: none;
        padding: 12px 20px;
        font-size: 15px;
        margin-bottom: 8px;
    }
    
    .save-btn, .export-btn, .import-btn {
        width: auto;
        min-width: 100px;
        max-width: 180px;
        padding: 8px 14px;
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    /* Allow time periods to stay in a row in landscape */
    .time-periods-selection {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: flex-start !important;
    }
    
    .time-period-checkbox {
        min-width: 120px !important;
        flex: 1 1 120px !important;
        max-width: 160px !important;
        margin: 0 4px 4px 0 !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .accessibility-bar {
        padding: 5px 10px;
    }
    .accessibility-bar-label {
        font-size: 12px;
        margin-right: 5px;
    }
    
    .accessibility-btn {
        padding: 3px 6px;
        font-size: 10px;
        gap: 3px;
    }
    
    /* Additional small screen adjustments */
    .lookup-btn {
        padding: 6px 10px;
        font-size: 11px;
        margin-left: 6px;
        width: auto;
        min-width: 70px;
    }
    
    .collapse-btn {
        padding: 6px 12px;
        font-size: 13px;
        width: auto;
        margin-bottom: 10px;
    }
    
    /* Form spacing adjustments */
    .form-row {
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .form-group input, .form-group textarea, .form-group select {
        padding: 10px;
        font-size: 13px;
    }
}

/* Barcode scanner help text */
.barcode-help {
    display: block;
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    font-style: italic;
}

/* Make help text high contrast in dark mode */
@media (prefers-color-scheme: dark) {
    .barcode-help {
        color: #aaa;
    }
}

/* Voice Status Container Styles */
.voice-status-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.dark-theme .voice-status-container {
    background-color: #2c3034;
    border-color: #495057;
    color: #f8f9fa;
}

.voice-status-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.voice-status-icon {
    font-size: 1.5rem;
    margin-right: 8px;
}

.voice-status-title {
    flex-grow: 1;
    font-weight: bold;
}

.voice-close-btn {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.voice-close-btn:hover {
    background-color: rgba(108, 117, 125, 0.1);
}

.voice-close-btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.voice-status-content {
    margin-bottom: 12px;
}

.voice-current-action {
    font-weight: bold;
    margin-bottom: 4px;
}

.voice-help-text {
    font-size: 0.9rem;
    color: #6c757d;
}

.dark-theme .voice-help-text {
    color: #adb5bd;
}

.voice-status-footer {
    display: flex;
    align-items: center;
    border-top: 1px solid #dee2e6;
    padding-top: 8px;
}

.dark-theme .voice-status-footer {
    border-color: #495057;
}

.voice-indicator-pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #dc3545;
    margin-right: 12px;
}

.voice-indicator-pulse.active {
    animation: pulse 1.5s infinite;
}

.voice-recognized-text {
    flex-grow: 1;
    font-style: italic;
    color: #6c757d;
    font-size: 0.9rem;
}

.dark-theme .voice-recognized-text {
    color: #adb5bd;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Accessibility styles for voice status container */
.high-contrast .voice-status-container {
    background-color: #000;
    border: 2px solid #fff;
    color: #fff;
}

.high-contrast .voice-help-text,
.high-contrast .voice-recognized-text {
    color: #fff;
}

.high-contrast .voice-indicator-pulse {
    background-color: #fff;
    box-shadow: 0 0 0 2px #000, 0 0 0 4px #fff;
}

.high-contrast .voice-close-btn {
    color: #fff;
    background-color: #000;
    border: 1px solid #fff;
}

.high-contrast .voice-status-footer {
    border-color: #fff;
}

/* Simplified Medication Cards for Pill Organizer Reference */
.medication-simple-info {
    text-align: center;
    margin: 10px 0;
}

.simple-info-item {
    margin: 5px 0;
    font-size: 1.1rem;
    color: #495057;
}

.simple-info-item strong {
    color: #2c3e50;
}

.small-btn {
    padding: 5px 8px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.small-btn.edit-btn {
    background: #e3f2fd;
    color: #1565c0;
}

.small-btn.edit-btn:hover {
    background: #bbdefb;
}

.small-btn.delete-btn {
    background: #ffebee;
    color: #c62828;
}

.small-btn.delete-btn:hover {
    background: #ffcdd2;
}

.card-actions {
    border-top: 1px solid #e9ecef;
    padding-top: 10px;
}

/* Adjust medication grid for better pill organizer layout */
.medication-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

/* Update card styles for cleaner pill organizer reference */
.medication-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
}

.medication-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.medication-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
    padding-bottom: 8px;
}

/* Hide time ranges and counts when empty (0 medications) */
.time-count[aria-label*="0"], 
.time-count:empty,
.time-count:contains("0") {
    display: none;
}

/* Always hide time ranges - not needed for pill organizer reference */
.time-range {
    display: none !important;
}

/* Alternative approach using data attributes */
.time-section[data-count="0"] .time-count {
    display: none;
}

/* Clean look for empty sections */
.time-section .time-header {
    padding: 20px;
    margin-bottom: 15px;
}

.time-section .time-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Show counts only when there are medications */
.time-section[data-count]:not([data-count="0"]) .time-count {
    display: block;
}

/* Responsive adjustments for cleaner empty state */
@media (max-width: 768px) {
    .time-section .time-header {
        padding: 15px;
    }
}

/* CTA Styles */
.cta-subtitle {
    margin: 10px 0 0 0;
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
}

/* Form Container and Header */
.medication-form-container {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 0;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    border-radius: 12px 12px 0 0;
}

.form-header h3 {
    margin: 0;
    color: #495057;
    font-size: 20px;
    font-weight: 600;
}

.collapse-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.collapse-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.collapse-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.3);
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .time-periods-selection {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .time-period-checkbox {
        flex: 1 1 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 6px 0 !important;
    }
}

/* Additional iOS-only viewport fixes - more specific to avoid affecting Android */
@supports (-webkit-touch-callout: none) and (-webkit-appearance: none) {
    @media screen and (max-device-width: 896px) and (-webkit-min-device-pixel-ratio: 2) {
        /* iPhone and iPad specific - uses iOS-specific features */
        .time-periods-selection {
            display: flex !important;
            flex-direction: column !important;
            gap: 8px !important;
            flex-wrap: nowrap !important;
        }
        
        .time-period-checkbox {
            flex: 1 1 100% !important;
            min-width: 100% !important;
            max-width: 100% !important;
            margin: 0 0 6px 0 !important;
        }
    }
}
