/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #EDEEF7;
}

/* Paper Texture Background */
.paper-texture {
    background-image: 
        radial-gradient(circle at 20px 80px, #B8B5FF 1px, transparent 1px),
        radial-gradient(circle at 80px 20px, rgba(120, 104, 230, 0.1) 1px, transparent 1px),
        radial-gradient(circle at 40px 40px, rgba(184, 181, 255, 0.05) 1px, transparent 1px);
    background-size: 100px 100px;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #7868E6 0%, #B8B5FF 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 4px 15px rgba(120, 104, 230, 0.3);
}

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-title .icon {
    font-size: 3rem;
}

.app-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Navigation */
.navigation {
    background: white;
    border-bottom: 3px solid #B8B5FF;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-list {
    list-style: none;
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: #7868E6;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    background: #B8B5FF;
    color: white;
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    padding: 3rem 0;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2.2rem;
    color: #7868E6;
    margin-bottom: 0.5rem;
}

.section-header p {
    font-size: 1.1rem;
    color: #666;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 3rem;
    background: linear-gradient(135deg, #E4FBFF, #B8B5FF);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-content h3 {
    font-size: 2rem;
    color: #7868E6;
    margin-bottom: 0.5rem;
}

.stat-content p {
    color: #666;
    font-weight: 500;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.child-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    transition: transform 0.3s ease;
}

.child-card:hover {
    transform: translateY(-5px);
}

.child-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.child-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #B8B5FF;
}

.child-avatar.placeholder {
    background: linear-gradient(135deg, #E4FBFF, #B8B5FF);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.child-info h3 {
    color: #7868E6;
    margin-bottom: 0.25rem;
}

.child-info p {
    color: #666;
    font-size: 0.9rem;
}

.child-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: #EDEEF7;
    border-radius: 10px;
}

.stat-item strong {
    display: block;
    color: #7868E6;
    font-size: 1.1rem;
}

.stat-item span {
    color: #666;
    font-size: 0.9rem;
}

/* Forms */
.form-card {
    background: white;
    padding: 2.5rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #7868E6;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E4FBFF;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #B8B5FF;
}

.form-group input:invalid {
    border-color: #FFB4B4;
}

/* Photo Upload */
.photo-upload {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.photo-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px dashed #B8B5FF;
    display: none;
}

.photo-preview.active {
    display: block;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #7868E6, #B8B5FF);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(120, 104, 230, 0.4);
}

.btn-secondary {
    background: #E4FBFF;
    color: #7868E6;
    border: 2px solid #B8B5FF;
}

.btn-secondary:hover {
    background: #B8B5FF;
    color: white;
}

.btn-danger {
    background: #FFB4B4;
    color: #8B0000;
}

.btn-danger:hover {
    background: #FF9999;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Child Selector */
.child-selector {
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    margin-bottom: 2rem;
}

.child-selector label {
    display: block;
    margin-bottom: 0.5rem;
    color: #7868E6;
    font-weight: 500;
}

.child-selector select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E4FBFF;
    border-radius: 8px;
    font-size: 1rem;
}

/* Measurements History */
.measurements-history {
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    overflow: hidden;
}

.measurements-table {
    width: 100%;
    border-collapse: collapse;
}

.measurements-table th,
.measurements-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #E4FBFF;
}

.measurements-table th {
    background: #7868E6;
    color: white;
    font-weight: 500;
}

.measurements-table tr:hover {
    background: #EDEEF7;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-normal {
    background: #90EE90;
    color: #006400;
}

.status-attention {
    background: #FFD700;
    color: #B8860B;
}

.status-alert {
    background: #FFB4B4;
    color: #8B0000;
}

/* Chart Controls */
.chart-controls {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
}

.control-group {
    flex: 1;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #7868E6;
    font-weight: 500;
}

.control-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E4FBFF;
    border-radius: 8px;
    font-size: 1rem;
}

/* Chart Container */
.chart-container {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    margin-bottom: 2rem;
    text-align: center;
}

#growth-chart {
    max-width: 100%;
    height: auto;
}

/* Chart Legend */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.legend-color.normal {
    background: #90EE90;
}

.legend-color.attention {
    background: #FFD700;
}

.legend-color.alert {
    background: #FFB4B4;
}

/* Export Options */
.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.export-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
    text-align: center;
}

.export-card h3 {
    color: #7868E6;
    margin-bottom: 1rem;
}

.export-card p {
    color: #666;
    margin-bottom: 1.5rem;
}

.import-section {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(120, 104, 230, 0.1);
}

.import-section h3 {
    color: #7868E6;
    margin-bottom: 1rem;
}

.import-card {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 90%;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #E4FBFF;
}

.modal-header h3 {
    color: #7868E6;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 1.5rem;
}

#camera-video {
    width: 100%;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Footer */
.footer {
    background: #7868E6;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer p {
    opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .app-title .icon {
        font-size: 2.5rem;
    }
    
    .nav-list {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .chart-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .legend-item {
        justify-content: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .import-card {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 2rem 0;
    }
    
    .form-card {
        padding: 1.5rem;
    }
    
    .section-header h2 {
        font-size: 1.8rem;
    }
    
    .export-options {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .navigation,
    .footer,
    .form-actions,
    .btn {
        display: none;
    }
    
    .paper-texture {
        background: white;
    }
    
    .content-section {
        display: block !important;
    }
}
