/* View Styles */
#settings-view, #history-view, #table-view, #summary-view {
    display: none;
}

/* Settings View */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h2 {
    margin-bottom: 15px;
}

/* ============================================
   REVAMPED TABLE VIEW
   ============================================ */

#table-view {
    padding: 0;
}

#table-view h2 {
    margin-bottom: 20px;
}

/* View tabs/toggle */
.view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.view-toggle button {
    padding: 10px 20px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #666;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-toggle button.active {
    background: var(--primary-color);
    color: white;
}

.view-toggle button:hover:not(.active) {
    background: #e0e0e0;
}

#table-container {
    overflow-x: auto;
    max-width: 100%;
    position: relative;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    background: white;
}

#habit-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

#habit-table th, #habit-table td {
    min-width: 55px;
    max-width: 55px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 12px 4px;
    text-align: center;
    font-size: 13px;
    background-color: #fafafa;
    transition: all 0.15s;
}

#habit-table th {
    background-color: #fff;
    font-weight: 600;
    color: #666;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 4px;
    border-bottom: 2px solid #f0f0f0;
}

#habit-table th.sticky-column, #habit-table td.sticky-column {
    position: sticky;
    left: 0;
    background-color: #fff;
    z-index: 1;
    border-right: 1px solid #eee;
    min-width: 160px;
    max-width: 200px;
    text-align: left;
    padding-left: 16px;
    font-weight: 500;
}

#habit-table th.sticky-column {
    z-index: 2;
    font-weight: 600;
}

#habit-table tr:hover td {
    background-color: #f8f9fa;
}

#habit-table tr:hover td.sticky-column {
    background-color: #fff;
}

#habit-table td.current-date {
    background-color: #e8f4fd;
}

#habit-table th.current-date {
    background-color: #e8f4fd;
    color: var(--primary-color);
}

#habit-table td.tracked-cell {
    background-color: #dcf5dd;
    color: var(--primary-color);
    font-weight: bold;
}

#habit-table td.tracked-cell.current-date {
    background-color: #c8f0ca;
}

.clickable-cell {
    cursor: pointer;
    border-radius: 4px;
}

#habit-table td.clickable-cell:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
}

#habit-table td.clickable-cell.tracked-cell:hover {
    background-color: #b8e8ba;
}

/* Archived habit row in table */
#habit-table tr.archived-habit td.sticky-column {
    opacity: 0.5;
    font-style: italic;
}

/* Habit name with color in table */
.table-habit-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-habit-name .category-dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

/* ============================================
   SUMMARY VIEW - Weekly/Monthly Stats
   ============================================ */

.summary-container {
    max-width: 800px;
    margin: 0 auto;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.summary-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.summary-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.summary-card-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}

.summary-card-label {
    font-size: 13px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.summary-section h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Weekly Grid */
.week-grid {
    overflow-x: auto;
}

.week-header, .week-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) repeat(7, 45px);
    gap: 8px;
    align-items: center;
}

.week-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.week-day {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
}

.week-day.today {
    color: var(--primary-color);
}

.week-habit-name {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.week-row {
    padding: 8px 0;
}

.week-row:not(:last-child) {
    border-bottom: 1px solid #f5f5f5;
}

.week-cell {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: #f5f5f5;
    transition: all 0.2s;
}

.week-cell.completed {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: white;
    font-weight: bold;
}

.week-cell.today {
    box-shadow: 0 0 0 2px var(--primary-color);
}

.week-cell.missed {
    background: #fff0f0;
}

/* Calendar Heatmap */
.heatmap-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.heatmap-day-label {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #999;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #666;
    background: #f0f0f0;
    cursor: default;
    transition: transform 0.15s;
    position: relative;
}

.heatmap-cell:hover:not(.empty) {
    transform: scale(1.1);
    z-index: 1;
}

.heatmap-cell.empty {
    background: transparent;
}

.heatmap-cell.future {
    opacity: 0.4;
}

.heatmap-cell.today {
    box-shadow: 0 0 0 2px var(--primary-color);
}

.heatmap-cell.level-0 { background: #f0f0f0; }
.heatmap-cell.level-1 { background: #c6e48b; }
.heatmap-cell.level-2 { background: #7bc96f; }
.heatmap-cell.level-3 { background: #449d44; color: white; }
.heatmap-cell.level-4 { background: #196127; color: white; }

.heatmap-date {
    font-weight: 500;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 16px;
    font-size: 11px;
    color: #888;
}

.heatmap-legend .heatmap-cell {
    width: 16px;
    height: 16px;
    min-width: 16px;
}

/* Habit Performance Bars */
.habit-performance {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.performance-item {
    padding: 12px 0;
}

.performance-item:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

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

.performance-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 14px;
}

.performance-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.performance-rate {
    font-weight: 700;
    font-size: 16px;
    color: #333;
}

.performance-streak {
    font-size: 13px;
    color: #888;
}

.performance-bar-bg {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.performance-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.no-data {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* ============================================
   HABIT TEMPLATES
   ============================================ */

.templates-section {
    margin-top: 30px;
}

.templates-grid {
    display: grid;
    gap: 16px;
}

.template-category {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.template-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.template-category-header h4 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.template-habits {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-habit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f5f7fa;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.template-habit:hover {
    background: #e8f4fd;
    border-color: var(--primary-color);
}

.template-habit.added {
    background: #dcf5dd;
    color: var(--primary-color);
}

.template-habit-icon {
    font-size: 16px;
}

/* ============================================
   HISTORY VIEW (Legacy - kept for reference)
   ============================================ */

.history-item {
    background-color: #f9f9f9;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 4px;
}

.history-date {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.history-habits {
    list-style-type: none;
    padding-left: 20px;
}

.history-habits li {
    margin-bottom: 5px;
    background-color: #e9e9e9;
    padding: 5px 10px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media screen and (max-width: 767px) {
    #habit-table th.sticky-column, #habit-table td.sticky-column {
        min-width: 120px;
        max-width: 140px;
        padding-left: 10px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .summary-card {
        padding: 20px;
    }

    .summary-card-value {
        font-size: 28px;
    }

    .week-header, .week-row {
        grid-template-columns: minmax(100px, 1fr) repeat(7, 36px);
        gap: 4px;
    }

    .week-cell {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .week-habit-name {
        font-size: 12px;
    }

    .heatmap-cell {
        font-size: 10px;
    }

    .template-habits {
        gap: 6px;
    }

    .template-habit {
        padding: 6px 10px;
        font-size: 12px;
    }
}
