/**
 * Personal Balance Tracker - Frontend Styles
 * Member Dashboard
 */

/* Variables */
:root {
    --pbt-primary: #4A7C59;
    --pbt-primary-light: #6B9B7A;
    --pbt-primary-dark: #3A6248;
    --pbt-bg: #F5F3EE;
    --pbt-bg-alt: #FDFCFA;
    --pbt-card-bg: #FFFFFF;
    --pbt-text: #333333;
    --pbt-text-light: #666666;
    --pbt-text-muted: #999999;
    --pbt-border: #E5E5E5;
    --pbt-success: #4A7C59;
    --pbt-warning: #E67E22;
    --pbt-radius: 16px;
    --pbt-radius-sm: 8px;
    --pbt-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --pbt-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* Dashboard Container */
.pbt-dashboard {
    background-color: var(--pbt-bg);
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    min-height: 100vh;
}

.pbt-dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Card Base */
.pbt-card {
    background: var(--pbt-card-bg);
    border-radius: var(--pbt-radius);
    padding: 24px;
    box-shadow: var(--pbt-shadow);
}

.pbt-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--pbt-text);
    margin: 0 0 16px 0;
}

/* Left Column */
.pbt-left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Balance Card */
.pbt-balance-card {
    text-align: center;
}

.pbt-progress-circle {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 16px;
}

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

.pbt-progress-circle circle {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
}

.pbt-progress-bg {
    stroke: #E8E8E8;
}

.pbt-progress-bar {
    stroke: var(--pbt-primary);
    transition: stroke-dashoffset 0.6s ease;
}

.pbt-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.pbt-progress-percentage {
    display: block;
    font-size: 36px;
    font-weight: 700;
    color: var(--pbt-text);
    line-height: 1;
}

.pbt-progress-label {
    display: block;
    font-size: 12px;
    color: var(--pbt-text-muted);
    margin-top: 4px;
}

.pbt-balance-message {
    font-size: 14px;
    color: var(--pbt-text-light);
    margin: 0;
    line-height: 1.5;
}

/* Quote Card */
.pbt-quote-card {
    background: linear-gradient(135deg, #F8F7F4 0%, #F5F3EE 100%);
    position: relative;
    padding-left: 45px;
    /* Increased to accommodate icon */
}

.pbt-quote-mark {
    position: absolute;
    left: 2px;
    top: 2px;
    font-size: 48px;
    color: var(--pbt-primary-light);
    opacity: 0.4;
    font-family: Georgia, serif;
    line-height: 1;
}

.pbt-quote-text {
    font-size: 14px;
    font-style: italic;
    color: var(--pbt-text);
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.pbt-quote-author {
    font-size: 13px;
    color: var(--pbt-primary);
    font-style: normal;
    font-weight: 500;
}

/* Streak Card */
.pbt-streak-card {
    text-align: center;
}

.pbt-streak-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pbt-streak-icon {
    font-size: 20px;
}

.pbt-weekly-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 80px;
    margin-bottom: 20px;
    padding: 0 8px;
}

.pbt-day-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 28px;
    height: 100%;
}

.pbt-bar-fill {
    width: 12px;
    background: var(--pbt-primary);
    border-radius: 6px;
    margin-top: auto;
    transition: height 0.3s ease;
    min-height: 4px;
}

.pbt-day-label {
    font-size: 11px;
    color: var(--pbt-text-muted);
    margin-top: 8px;
    text-transform: uppercase;
}

.pbt-streak-count {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
}

.pbt-streak-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--pbt-text);
}

.pbt-streak-label {
    font-size: 16px;
    color: var(--pbt-text-light);
}

.pbt-streak-message {
    font-size: 13px;
    color: var(--pbt-text-muted);
    margin: 8px 0 0 0;
}

/* Right Column - Checklists */
.pbt-right-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.pbt-checklist-section {
    background: var(--pbt-card-bg);
    border-radius: var(--pbt-radius);
    padding: 20px 24px;
    box-shadow: var(--pbt-shadow);
}

.pbt-checklist-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--pbt-text);
    margin: 0 0 16px 0;
}

.pbt-checklist-icon {
    font-size: 20px;
}

/* Habit Items */
.pbt-habits-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pbt-habit-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--pbt-bg-alt);
    border-radius: var(--pbt-radius-sm);
    transition: all 0.2s ease;
}

.pbt-habit-item:hover {
    background: #F0EDE8;
}

.pbt-habit-item.completed {
    opacity: 0.7;
}

.pbt-habit-item.completed .pbt-habit-title {
    text-decoration: line-through;
    color: var(--pbt-text-muted);
}

/* Custom Checkbox */
.pbt-habit-checkbox {
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.pbt-habit-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pbt-checkmark {
    display: block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--pbt-border);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.pbt-habit-checkbox:hover .pbt-checkmark {
    border-color: var(--pbt-primary);
}

.pbt-habit-checkbox input:checked+.pbt-checkmark {
    background: var(--pbt-primary);
    border-color: var(--pbt-primary);
}

.pbt-habit-checkbox input:checked+.pbt-checkmark::after {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    height: 100%;
}

/* Habit Content */
.pbt-habit-content {
    flex: 1;
    min-width: 0;
}

.pbt-habit-title {
    display: block;
    font-size: 16px;
    /* Increased from 15px */
    font-weight: 500;
    color: var(--pbt-text);
    transition: all 0.2s ease;
}

.pbt-habit-desc {
    display: block;
    font-size: 14px;
    /* Increased from 13px */
    color: var(--pbt-text-muted);
    margin-top: 2px;
}

/* Habit Actions */
.pbt-habit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pbt-done-badge {
    display: inline-block;
    padding: 4px 12px;
    background: var(--pbt-primary);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
}

.pbt-replay-btn,
.pbt-journal-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--pbt-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--pbt-text-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.pbt-replay-btn:hover,
.pbt-journal-btn:hover {
    border-color: var(--pbt-primary);
    color: var(--pbt-primary);
}

.pbt-replay-icon {
    font-size: 14px;
}

.pbt-info-icon {
    color: var(--pbt-text-muted);
    cursor: help;
}

/* No Checklists */
.pbt-no-checklists {
    text-align: center;
    padding: 48px 24px;
    background: var(--pbt-card-bg);
    border-radius: var(--pbt-radius);
}

.pbt-no-checklists p {
    color: var(--pbt-text-light);
    margin: 0;
}

/* Login Required */
.pbt-login-required {
    text-align: center;
    padding: 48px 24px;
    background: var(--pbt-card-bg);
    border-radius: var(--pbt-radius);
    max-width: 400px;
    margin: 48px auto;
}

.pbt-login-btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--pbt-primary);
    color: white;
    text-decoration: none;
    border-radius: var(--pbt-radius-sm);
    font-weight: 500;
    margin-top: 16px;
}

.pbt-login-btn:hover {
    background: var(--pbt-primary-dark);
    color: white;
}

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

.pbt-modal-content {
    background: var(--pbt-card-bg);
    border-radius: var(--pbt-radius);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.pbt-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--pbt-bg);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    color: var(--pbt-text-light);
}

.pbt-modal-close:hover {
    background: var(--pbt-border);
}

.pbt-modal-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.pbt-modal-desc {
    font-size: 14px;
    color: var(--pbt-text-light);
    margin: 0 0 20px 0;
}

#pbt-journal-notes {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--pbt-border);
    border-radius: var(--pbt-radius-sm);
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

#pbt-journal-notes:focus {
    outline: none;
    border-color: var(--pbt-primary);
}

.pbt-submit-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--pbt-primary);
    color: white;
    border: none;
    border-radius: var(--pbt-radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 16px;
}

.pbt-submit-btn:hover {
    background: var(--pbt-primary-dark);
}

/* Profile Button */
.pbt-profile-button {
    margin-top: 10px;
}

.pbt-balance-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    background: var(--pbt-primary) !important;
    color: white !important;
    border: none !important;
}

.pbt-balance-btn:hover {
    background: var(--pbt-primary-dark) !important;
}

/* Responsive */
@media (max-width: 900px) {
    .pbt-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .pbt-left-column {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .pbt-dashboard {
        padding: 16px;
    }

    .pbt-habit-item {
        flex-wrap: wrap;
    }

    .pbt-habit-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
        padding-left: 40px;
    }
}

/* Stats View Toggle */
.pbt-streak-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pbt-view-toggle {
    display: flex;
    background: #f0f0f0;
    padding: 3px;
    border-radius: 8px;
}

.pbt-toggle-btn {
    background: none;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pbt-toggle-btn.active {
    background: #fff;
    color: var(--pbt-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.pbt-view-content {
    display: none;
}

.pbt-view-content.active {
    display: block;
}

/* Calendar View */
.pbt-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.pbt-month-label {
    font-weight: 600;
    color: #333;
}

.pbt-month-nav {
    background: none;
    border: 1px solid #eee;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    color: #666;
    font-size: 18px;
    line-height: 1;
    padding-bottom: 2px;
}

.pbt-month-nav:hover {
    border-color: var(--pbt-primary);
    color: var(--pbt-primary);
}

.pbt-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.pbt-cal-head {
    font-size: 11px;
    color: #999;
    padding-bottom: 8px;
}

.pbt-cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #FAFAFA;
    border-radius: 4px;
    font-size: 12px;
    position: relative;
    border: 1px solid transparent;
}

.pbt-cal-day.complete {
    background: #D1FAE5;
    color: #065F46;
    font-weight: 600;
}

.pbt-cal-day.partial {
    background: #FEF3C7;
    color: #92400E;
}

.pbt-cal-day.future {
    background: #fff;
    color: #eee;
}

.pbt-loading-month {
    padding: 30px;
    text-align: center;
}