/* Root Variables */
:root {
    --primary: #1A237E;
    --primary-dark: #0D1642;
    --primary-light: #534BAE;
    --secondary: #E8EAF6;
    --accent: #FF6F00;
    --accent-light: #FFA040;
    --background: #F5F5F5;
    --surface: #FFFFFF;
    --error: #D32F2F;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-disabled: #BDBDBD;
    --divider: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    width: 100%;
    overflow-x: hidden;
}

body {
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: pan-y;
    user-select: none;
}

/* App Container */
#app {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    background-color: var(--background);
    min-height: 100vh;
    position: relative;
}

/* App Bar */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    z-index: 100;
    box-shadow: 0 2px 4px var(--shadow);
}

.app-bar h1 {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.15px;
}

.app-bar .icon-button {
    position: absolute;
    right: 8px;
}

/* Main Content */
#main-content {
    padding: 72px 12px 88px;
    min-height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Cards */
.card {
    background-color: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 3px var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--divider);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 500;
}

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

.stat-card {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--secondary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-content p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Activity List */
.activity-list {
    padding: 8px 0;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.activity-item:active {
    background-color: var(--secondary);
}

.activity-item .material-icons {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background-color: var(--secondary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
}

.activity-info h4 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 2px;
}

.activity-info p {
    font-size: 14px;
    color: var(--text-secondary);
}

.activity-meta {
    text-align: right;
    font-size: 14px;
}

.activity-meta .duration {
    font-weight: 500;
    color: var(--accent);
}

.activity-meta .date {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Bar Chart */
.chart-container {
    padding: 16px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 180px;
    gap: 8px;
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bar {
    width: 100%;
    background: linear-gradient(180deg, var(--accent), var(--accent-light));
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: all 0.3s ease;
}

.bar-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--surface);
    border-radius: 28px;
    padding: 8px 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px var(--shadow);
}

.search-bar .material-icons {
    color: var(--text-secondary);
    margin-right: 8px;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
}

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 8px 16px;
    border-radius: 16px;
    border: 1px solid var(--divider);
    background-color: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.chip:active {
    transform: scale(0.95);
}

.chip.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* List Container */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}

.list-item:active {
    transform: scale(0.98);
}

.list-item .material-icons {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--secondary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.list-item-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-item-trailing {
    text-align: right;
}

.list-item-trailing .duration {
    font-size: 18px;
    font-weight: 500;
    color: var(--accent);
}

.list-item-trailing .date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 80px;
    color: var(--text-disabled);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Goal Progress */
.goal-progress {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.circular-progress {
    position: relative;
    width: 160px;
    height: 160px;
}

.circular-progress svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-bg {
    fill: none;
    stroke: var(--secondary);
    stroke-width: 8;
}

.progress-bar {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 500;
    color: var(--accent);
}

.goal-details {
    text-align: center;
}

.goal-details p {
    font-size: 16px;
    margin-bottom: 4px;
}

/* Milestones List */
.milestones-list {
    padding: 8px 0;
}

.milestone-item {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 16px;
}

.milestone-item .material-icons {
    font-size: 32px;
    color: var(--text-disabled);
}

.milestone-item.achieved .material-icons {
    color: var(--accent);
}

.milestone-item h4 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.milestone-item p {
    font-size: 14px;
    color: var(--text-secondary);
}

.milestone-item.achieved {
    opacity: 1;
}

.milestone-item:not(.achieved) {
    opacity: 0.6;
}

/* Overview Stats */
.overview-stats {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.overview-item {
    text-align: center;
}

.overview-item h3 {
    font-size: 20px;
    font-weight: 500;
    margin-top: 8px;
}

/* Breakdown List */
.breakdown-list {
    padding: 8px 0;
}

.breakdown-item {
    padding: 12px 16px;
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.breakdown-name {
    font-size: 16px;
    font-weight: 500;
}

.breakdown-value {
    font-size: 16px;
    font-weight: 500;
    color: var(--accent);
}

.breakdown-bar {
    height: 6px;
    background-color: var(--secondary);
    border-radius: 3px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Line Chart */
.line-chart {
    height: 200px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 4px;
}

.line-point {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 0;
}

.line-point .point-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    min-height: 120px;
}

.point {
    width: 100%;
    min-height: 4px;
    background-color: var(--accent);
    border-radius: 4px;
}

.point-label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 72px;
    background-color: var(--surface);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 4px var(--shadow);
    z-index: 100;
    overflow-x: auto;
    scrollbar-width: none;
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    flex: 0 0 auto;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.nav-item .material-icons {
    font-size: 24px;
}

.nav-item span:last-child {
    font-size: 10px;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item:active {
    transform: scale(0.95);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 88px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background-color: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 8px var(--shadow-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 90;
}

.fab .material-icons {
    font-size: 24px;
}

.fab:active {
    transform: scale(0.9);
}

.fab.hide {
    transform: scale(0);
}

/* Bottom Sheet */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    width: 100%;
    max-height: 90vh;
    background-color: var(--surface);
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -4px 16px var(--shadow-strong);
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-content {
    padding: 24px;
}

.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.bottom-sheet-header h2 {
    font-size: 24px;
    font-weight: 500;
}

/* Form */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Roboto', sans-serif;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
    flex: 1;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:active {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid var(--divider);
}

.btn-secondary:active {
    background-color: var(--secondary);
}

.btn-danger {
    background-color: var(--error);
    color: white;
}

.btn-danger:active {
    opacity: 0.9;
}

.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.icon-button:active {
    background-color: rgba(255, 255, 255, 0.2);
}

.app-bar .icon-button {
    color: white;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 150;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Dialog */
.dialog {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 24px;
}

.dialog.active {
    opacity: 1;
    visibility: visible;
}

.dialog-content {
    background-color: var(--surface);
    border-radius: 16px;
    padding: 24px;
    max-width: 340px;
    width: 100%;
    box-shadow: 0 8px 16px var(--shadow-strong);
    animation: dialogSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dialogSlideIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.dialog-content h3 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 16px;
}

.dialog-content p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.dialog-actions button {
    flex: 1;
}

/* Text Utilities */
.text-secondary {
    color: var(--text-secondary);
}

.text-disabled {
    color: var(--text-disabled);
}

/* Responsive */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .fab {
        right: 16px;
    }
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--divider) 25%, var(--background) 50%, var(--divider) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Chat Styles */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

.chat-message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 24px;
}

.ai-message .chat-avatar {
    background-color: var(--secondary);
    color: var(--primary);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .chat-avatar {
    background-color: var(--accent);
    color: white;
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    background-color: var(--surface);
    box-shadow: 0 1px 2px var(--shadow);
}

.user-message .chat-bubble {
    background-color: var(--primary);
    color: white;
}

.chat-bubble p {
    margin: 0;
    line-height: 1.5;
    font-size: 15px;
}

.chat-input-container {
    position: fixed;
    bottom: 72px;
    left: 0;
    right: 0;
    width: 100%;
    padding: 12px 12px;
    background-color: var(--surface);
    border-top: 1px solid var(--divider);
    display: flex;
    gap: 8px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: 24px;
    outline: none;
    font-size: 15px;
    font-family: 'Roboto', sans-serif;
    background-color: var(--background);
}

#chat-input:focus {
    border-color: var(--primary);
}

#send-btn {
    background-color: var(--primary);
    color: white;
}

#send-btn:active {
    background-color: var(--primary-dark);
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Library Styles */
.library-tabs {
    display: flex;
    gap: 8px;
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.library-tabs::-webkit-scrollbar {
    display: none;
}

.library-tab {
    padding: 8px 16px;
    border-radius: 16px;
    border: 1px solid var(--divider);
    background-color: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.library-tab:active {
    transform: scale(0.95);
}

.library-tab.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.resource-item {
    background-color: var(--surface);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    margin-bottom: 8px;
}

.resource-item:active {
    transform: scale(0.98);
}

.resource-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background-color: var(--secondary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.resource-icon .material-icons {
    font-size: 24px;
}

.resource-content {
    flex: 1;
}

.resource-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 4px;
}

.resource-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

.resource-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background-color: var(--secondary);
    color: var(--primary);
    margin-right: 8px;
}

.form-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Roboto', sans-serif;
    background-color: var(--surface);
}

.form-group select:focus {
    border-color: var(--primary);
}
