/* Enhanced Medical Records API Interface Styles */

/* Reset and base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    animation: slideIn 0.5s ease-out;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 20px 30px;
    text-align: center;
    position: relative;
}

.header h1 {
    margin: 0 0 10px 0;
    font-size: 2.2em;
    font-weight: 300;
}

.header p {
    margin: 0;
    opacity: 0.9;
    font-size: 1.1em;
}

/* Status bar */
.status-bar {
    background: rgba(255,255,255,0.1);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    background: #28a745;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: #dc3545;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Controls */
.controls {
    background: #f8f9fa;
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.control-group select {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    background: white;
    font-size: 1em;
    transition: all 0.3s ease;
}

.control-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Content area */
.content {
    padding: 30px;
    min-height: 400px;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.loading::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Error state */
.error {
    text-align: center;
    padding: 40px 20px;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin: 20px 0;
}

.error h3 {
    margin-top: 0;
    color: #721c24;
}

/* Counts summary */
.counts-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.count-card {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.count-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.count-number {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.count-label {
    display: block;
    font-size: 0.9em;
    opacity: 0.9;
}

/* Resident grid */
.resident-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.resident-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.resident-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.resident-name {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
}

.resident-info {
    color: #6c757d;
    margin-bottom: 15px;
    line-height: 1.5;
}

.resident-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.data-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
}

.has-data {
    background: #d4edda;
    color: #155724;
}

.no-data {
    background: #f8d7da;
    color: #721c24;
}

/* Record detail view */
.resident-detail-header {
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    border-radius: 10px;
}

.resident-detail-header h2 {
    margin: 0 0 15px 0;
    font-size: 2em;
    font-weight: 300;
}

.resident-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.back-button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    margin-bottom: 20px;
    transition: background 0.3s ease;
}

.back-button:hover {
    background: #5a6268;
}

/* Record sections */
.record-detail {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.record-header {
    background: #f8f9fa;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #e9ecef;
    transition: background 0.3s ease;
}

.record-header:hover {
    background: #e9ecef;
}

.expand-icon {
    transition: transform 0.3s ease;
}

.expand-icon.expanded {
    transform: rotate(180deg);
}

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

.record-content.active {
    max-height: none;
    padding: 20px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

.empty-state h3 {
    margin-top: 0;
    color: #495057;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .controls {
        padding: 15px 20px;
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .button-group {
        justify-content: stretch;
    }
    
    .btn {
        flex: 1;
        justify-content: center;
    }
    
    .content {
        padding: 20px;
    }
    
    .counts-summary {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .resident-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .resident-detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .container {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .controls {
        background: #34495e;
        border-color: #4a5568;
    }
    
    .control-group select {
        background: #4a5568;
        border-color: #718096;
        color: #ecf0f1;
    }
    
    .resident-card {
        background: #34495e;
        border-color: #4a5568;
        color: #ecf0f1;
    }
    
    .record-detail {
        background: #34495e;
        border-color: #4a5568;
    }
    
    .record-header {
        background: #4a5568;
        color: #ecf0f1;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
    animation: slideUp 0.5s ease-out;
}

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