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

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background: #EDEEF7;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(184, 181, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(120, 104, 230, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 180, 180, 0.1) 0%, transparent 50%);
    min-height: 100vh;
}

:root {
    --header-offset: 120px;
}
.black-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 30px;
background-color: #000000;
z-index: 1001;
}
/* Paper texture effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0.1) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0.1) 4px
        );
    pointer-events: none;
    z-index: -1;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, #7868E6, #B8B5FF);
    color: white;
    padding: 2rem 0;
    text-align: left;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 120;
}

.header-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
}

.header-logo {
    height: 56px;
    width: auto;
    border-radius: 8px;
    display: block;
}

.header-texts {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.header-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.header-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Navigation */
.navigation {
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: var(--header-offset);
    z-index: 100;
}

.nav-list {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-link {
    display: block;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: #7868E6;
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-link:hover,
.nav-link.active {
    background: #EDEEF7;
    border-bottom-color: #7868E6;
    color: #7868E6;
}

/* Main content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Reserve space for bottom nav on mobile */
.main.has-bottom-nav {
    padding-bottom: 80px;
}

.section {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.section.active {
    display: block;
}

.section-title {
    font-size: 2rem;
    color: #7868E6;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Forms */
.sleep-form {
    max-width: 600px;
    margin: 0 auto;
}

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

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

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

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #7868E6;
    box-shadow: 0 0 0 3px rgba(120, 104, 230, 0.1);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Quality scale */
.quality-scale {
    text-align: center;
}

.quality-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #E4FBFF;
    outline: none;
    margin-bottom: 1rem;
    -webkit-appearance: none;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #7868E6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.quality-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #7868E6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.quality-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.quality-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #7868E6;
}

/* Positions diagram */
.positions-diagram {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.position-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 2px solid #E4FBFF;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.position-option:hover {
    border-color: #7868E6;
    background: #EDEEF7;
}

.position-option.selected {
    border-color: #7868E6;
    background: #E4FBFF;
}

.position-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.position-icon {
    width: 40px;
    height: 60px;
    border-radius: 20px;
    margin-bottom: 0.5rem;
    position: relative;
}

.position-icon.left-side {
    background: linear-gradient(135deg, #FFB4B4, #FF9999);
    transform: rotate(-90deg);
}

.position-icon.right-side {
    background: linear-gradient(135deg, #B8B5FF, #9999FF);
    transform: rotate(90deg);
}

.position-icon.back {
    background: linear-gradient(135deg, #7868E6, #6B5CE6);
}

.position-icon.stomach {
    background: linear-gradient(135deg, #E4FBFF, #B8F5FF);
}

.position-icon::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

/* Buttons */
.btn {
    background: #7868E6;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: #6B5CE6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(120, 104, 230, 0.3);
}

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

.btn-secondary {
    background: #E4FBFF;
    color: #7868E6;
}

.btn-secondary:hover {
    background: #B8F5FF;
    color: #7868E6;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters .form-input {
    flex: 1;
    min-width: 150px;
}

/* Sleep history */
.sleep-history {
    display: grid;
    gap: 1rem;
}

.sleep-record {
    background: #EDEEF7;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #7868E6;
}

.sleep-record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sleep-record-date {
    font-size: 1.2rem;
    font-weight: bold;
    color: #7868E6;
}

.sleep-record-quality {
    background: #7868E6;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
}

.sleep-record-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.sleep-record-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(120, 104, 230, 0.1);
}

.sleep-record-item:last-child {
    border-bottom: none;
}

.sleep-record-label {
    font-weight: 600;
    color: #666;
}

.sleep-record-value {
    color: #7868E6;
    font-weight: 500;
}

.sleep-record-positions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.position-badge {
    background: #E4FBFF;
    color: #7868E6;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.sleep-record-notes {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(120, 104, 230, 0.1);
    font-style: italic;
    color: #666;
}

.delete-record {
    background: #FFB4B4;
    color: #CC0000;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.delete-record:hover {
    background: #FF9999;
    transform: translateY(-1px);
}

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

.report-card {
    background: #EDEEF7;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

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

.report-card canvas {
    max-width: 100%;
    height: auto;
}

/* FAQ */
.faq-section {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-question {
    padding: 1.5rem;
    background: #EDEEF7;
    color: #7868E6;
    cursor: pointer;
    margin: 0;
    font-size: 1.1rem;
    position: relative;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: #E4FBFF;
}

.faq-question::after {
    content: '+';
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question::after {
    transform: translateY(-50%) rotate(45deg);
}

.faq-answer {
    padding: 0 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item.active .faq-answer {
    padding: 1.5rem;
    max-height: 500px;
}

.faq-answer p {
    color: #666;
    line-height: 1.6;
}

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

.footer p {
    margin: 0;
    opacity: 0.9;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    :root { --header-offset: 0px; }
    
    .header {
        text-align: center;
    }

    .header-wrap {
        flex-direction: column;
        gap: 10px;
    }

    .header-logo {
        height: 44px;
    }

    .header-texts {
        align-items: center;
    }

    .header-title {
        font-size: 2rem;
    }
    
    .header-subtitle {
        font-size: 1rem;
    }
    
    .nav-list {
        flex-direction: column;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .section {
        padding: 1.5rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .positions-diagram {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters .form-input {
        min-width: auto;
    }
    
    .sleep-record-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sleep-record-details {
        grid-template-columns: 1fr;
    }
    
    .reports-container {
        grid-template-columns: 1fr;
    }

    /* Hide top navigation and use bottom nav on mobile */
    .navigation {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 1.5rem;
    }
    
    .section {
        padding: 1rem;
    }
    
    .positions-diagram {
        grid-template-columns: 1fr;
    }
    
    .quality-labels {
        font-size: 0.7rem;
    }
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: none;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
    margin-bottom: 80px;
}

.bottom-nav .nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    color: #7868E6;
    text-decoration: none;
    font-weight: 500;
}

.bottom-nav .nav-link .icon {
    display: inline-flex;
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.bottom-nav .nav-link .label {
    font-size: 0.75rem;
}

.bottom-nav .nav-link.active,
.bottom-nav .nav-link:hover {
    color: #5a4fd6;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }
}

/* Loading and error states */
.loading {
    text-align: center;
    padding: 2rem;
    color: #7868E6;
}

.error {
    background: #FFB4B4;
    color: #CC0000;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
}

.success {
    background: #B8F5FF;
    color: #007ACC;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section.active {
    animation: fadeIn 0.5s ease-out;
}

.sleep-record {
    animation: fadeIn 0.3s ease-out;
}

/* Print styles */
@media print {
    .navigation,
    .footer,
    .btn {
        display: none;
    }
    
    .section {
        display: block !important;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    body {
        background: white;
    }
    
    .header {
        background: white;
        color: black;
        box-shadow: none;
        border-bottom: 2px solid #ccc;
    }
}
