/* Custom Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-scale: 1;
}

html.dark-mode {
    color-scheme: dark;
}

html.font-small {
    --font-scale: 0.85;
}

html.font-large {
    --font-scale: 1.15;
}

html.font-xlarge {
    --font-scale: 1.3;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #333;
    background: white;
    transition: background-color 0.3s ease, color 0.3s ease;
}

html.dark-mode body {
    background: #1a1a1a;
    color: #e5e5e5;
}

body {
    font-size: calc(16px * var(--font-scale));
}

/* Patient Card Styles */
.patient-card {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    background: white;
    display: flex;
    flex-direction: column;
}

.patient-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* Grid Layout Options */
#patientsGrid {
    display: grid;
    gap: 1rem;
}

#patientsGrid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

#patientsGrid.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

#patientsGrid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

#patientsGrid.grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.patient-photo {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
    flex-shrink: 0;
}

.patient-info {
    padding: 12px;
}

.patient-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patient-age {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.patient-status {
    font-size: 11px;
    padding: 4px 8px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 4px;
    display: inline-block;
}

/* Modal Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#addPatientModal:not(.hidden) {
    animation: slideUp 0.3s ease;
}

#addPatientModal:not(.hidden) > div {
    animation: slideUp 0.3s ease;
}

/* Input Focus Styles */
input:focus, textarea:focus {
    transition: all 0.3s ease;
}

/* Dark Mode - Search Input */
html.dark-mode input,
html.dark-mode textarea {
    background-color: #2a2a2a;
    color: #e5e5e5;
    border-color: #404040;
}

html.dark-mode input::placeholder,
html.dark-mode textarea::placeholder {
    color: #999;
}

html.dark-mode input:focus,
html.dark-mode textarea:focus {
    border-color: #3b82f6;
    background-color: #333;
}

/* Dark Mode - Buttons */
html.dark-mode .bg-gray-50 {
    background-color: #242424;
}

html.dark-mode .bg-white {
    background-color: #2a2a2a;
    color: #e5e5e5;
}

html.dark-mode button:not([class*="bg-green"]):not([class*="bg-blue"]) {
    color: #e5e5e5;
}

html.dark-mode .border-b {
    border-color: #404040;
}

html.dark-mode .text-gray-800 {
    color: #e5e5e5;
}

html.dark-mode .text-gray-700 {
    color: #d0d0d0;
}

html.dark-mode .patient-card {
    background: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

html.dark-mode .patient-name {
    color: #e5e5e5;
}

html.dark-mode .patient-age {
    color: #b0b0b0;
}

html.dark-mode .patient-status {
    background: #1e3a8a;
    color: #93c5fd;
}

html.dark-mode .no-patients {
    color: #606060;
}

/* Dark Mode - Modal */
html.dark-mode #addPatientModal > div {
    background: #2a2a2a;
    color: #e5e5e5;
}

html.dark-mode label {
    color: #d0d0d0;
}

html.dark-mode input[type="text"],
html.dark-mode input[type="number"],
html.dark-mode input[type="tel"],
html.dark-mode textarea {
    background-color: #374151;
    color: #e5e5e5;
    border-color: #4b5563;
}

html.dark-mode input[type="text"]:focus,
html.dark-mode input[type="number"]:focus,
html.dark-mode input[type="tel"]:focus,
html.dark-mode textarea:focus {
    background-color: #3f4959;
    border-color: #3b82f6;
}

/* Camera Modal Styles */
#cameraVideo {
    display: block;
    width: 100%;
    transform: scaleX(-1);
}

#cameraModal > div {
    max-height: 90vh;
}

html.dark-mode #cameraModal > div {
    background: #2a2a2a;
    color: #e5e5e5;
}

/* Loading Spinner Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Font Size Scaling */
h1, h2 {
    font-size: calc(var(--font-size-lg) * var(--font-scale));
}

p, label, input, textarea, button, .patient-name, .patient-age {
    font-size: calc(16px * var(--font-scale));
}

.text-sm {
    font-size: calc(14px * var(--font-scale));
}

.text-xs {
    font-size: calc(12px * var(--font-scale));
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* No patients message */
.no-patients {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.no-patients svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

/* Grid Layout Buttons */
#grid2, #grid3, #grid4, #grid5 {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
    transition: all 0.3s ease;
}

html.dark-mode #grid2,
html.dark-mode #grid3,
html.dark-mode #grid4,
html.dark-mode #grid5 {
    color: #d1d5db;
}

#grid2.bg-white, #grid3.bg-white, #grid4.bg-white, #grid5.bg-white {
    background-color: #3b82f6;
    color: white;
}

html.dark-mode #grid2.bg-white,
html.dark-mode #grid3.bg-white,
html.dark-mode #grid4.bg-white,
html.dark-mode #grid5.bg-white {
    background-color: #3b82f6;
    color: white;
}

html.dark-mode .is-dark-mode-grid-buttons {
    background-color: #374151;
}

/* Details Toggle Button Styles */
#detailsToggleBtn {
    transition: all 0.3s ease;
}

#detailsToggleBtn.bg-white {
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

html.dark-mode #detailsToggleBtn.bg-white {
    background-color: #3b82f6;
    color: white;
}
