* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.4;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.header {
    background: #3B82F6;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sync-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.25rem;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s;
}

.sync-btn:active {
    transform: scale(0.95);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 8px 16px;
    border-top: 1px solid #e0e0e0;
    z-index: 100;
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn.active {
    color: #3B82F6;
}

.nav-icon {
    font-size: 1.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 16px;
    padding-bottom: 80px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Search Bar */
.search-bar {
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    font-size: 16px;
}

/* Lists */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.1s;
}

.card:active {
    transform: scale(0.98);
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
}

.card-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.card-detail {
    font-size: 0.875rem;
    color: #9ca3af;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 8px;
}

.badge-pending {
    background: #fef3c7;
    color: #d97706;
}

.badge-confirmed {
    background: #dbeafe;
    color: #2563eb;
}

.badge-completed {
    background: #d1fae5;
    color: #059669;
}

.badge-cancelled {
    background: #fee2e2;
    color: #dc2626;
}

/* Forms */
.form-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: white;
    border-radius: 12px;
    padding: 4px;
}

.form-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.form-tab.active {
    background: #3B82F6;
    color: white;
}

.form {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.form.active-form {
    display: flex;
}

.form-input {
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #3B82F6;
}

.btn-primary {
    background: #3B82F6;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:active {
    background: #2563eb;
}

.btn-primary.small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header h2 {
    font-size: 1.125rem;
}

.filter-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: white;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.empty-state span {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

/* ========== ESTILOS HISTORIAL MÉDICO ========== */

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.medical-modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.modal-header h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.modal-header p {
    font-size: 0.75rem;
    opacity: 0.9;
}

.close-modal-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Medical Tabs */
.medical-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.medical-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 20px;
    transition: all 0.2s;
}

.medical-tab.active {
    background: #3B82F6;
    color: white;
}

/* Medical Panels */
.medical-panels {
    padding: 20px;
}

.medical-panel {
    display: none;
}

.medical-panel.active {
    display: block;
}

.panel-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
}

.stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 4px;
}

.last-vitals {
    background: #f9fafb;
    border-radius: 12px;
    padding: 16px;
}

.last-vitals h4 {
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.vitals-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.vitals-summary span {
    background: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
}

/* Clinical Notes */
.clinical-note {
    background: #f9fafb;
    border-left: 4px solid #3B82F6;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.note-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.note-date {
    font-size: 0.75rem;
    color: #9ca3af;
}

.note-doctor {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 8px;
}

.note-content {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.note-type {
    display: inline-block;
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.625rem;
    text-transform: uppercase;
}

/* Vital Signs */
.vital-record {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.vital-date {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 12px;
}

.vital-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.vital-label {
    font-size: 0.75rem;
    color: #6b7280;
}

.vital-notes {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

/* Medications */
.medication-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.medication-item.inactive {
    opacity: 0.6;
    background: #f9fafb;
}

.med-name {
    font-weight: 600;
    margin-bottom: 8px;
}

.med-detail {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.med-date {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 8px;
}

.med-notes {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 8px 0;
}

.btn-small {
    background: #f3f4f6;
    border: none;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 8px;
}

/* Documents */
.document-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.doc-icon {
    font-size: 1.5rem;
}

.doc-info {
    flex: 1;
}

.doc-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.doc-date {
    font-size: 0.75rem;
    color: #9ca3af;
}

.doc-notes {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 4px;
}

/* Surgery Items */
.surgery-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.surgery-name {
    font-weight: 600;
    margin-bottom: 8px;
}

.surgery-date {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.surgery-detail {
    font-size: 0.75rem;
    color: #9ca3af;
}

.surgery-notes {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 8px;
}

/* Family History */
.family-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

.family-relative {
    font-weight: 500;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.family-condition {
    font-size: 0.875rem;
}

.family-notes {
    font-size: 0.75rem;
    color: #6b7280;
}

/* No Data */
.no-data {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
}

/* Modal Forms */
.modal-form-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-form-overlay {
    background: white;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-form-content {
    padding: 20px;
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #9ca3af;
}

.modal-form h3 {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    color: #374151;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.875rem;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #3B82F6;
}

/* Responsive */
@media (max-width: 480px) {
    .main-content {
        padding: 12px;
        padding-bottom: 80px;
    }
    
    .card {
        padding: 14px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .medical-modal-content {
        max-height: 90vh;
    }
}