/* Essential styles for habit detail view */

/* Animation styles */
#habitDetailView {
    transform: translateX(100%);
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
    background-color: #f8f9fa;
    box-shadow: -5px 0 15px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    z-index: 1050;
}

/* Fix show class styles to ensure visibility on all screen sizes */
#habitDetailView.show {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Modified hiding styles to ensure smooth transition */
#habitDetailView.hiding {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Backdrop styles */
#habitDetailBackdrop {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#habitDetailBackdrop.hiding {
    opacity: 0;
}

/* Mobile specific styles - explicitly added */
@media (max-width: 575.98px) {
    #habitDetailView {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        right: 0 !important;
        left: auto !important;
        border-radius: 0 !important;
        transform: translateX(100%) !important;
    }
    
    #habitDetailView.show {
        transform: translateX(0) !important;
    }
    
    #habitDetailView.hiding {
        transform: translateX(100%) !important;
    }
}

/* Desktop view adjustments with better specific styles */
@media (min-width: 576px) {
    #habitDetailView {
        width: 500px !important;
        max-width: 90% !important;
        left: 50% !important;
        transform: translateX(-50%) translateX(100%) !important;
        border-radius: 15px !important;
        height: 90% !important;
        top: 5% !important;
        max-height: 760px !important;
        box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
    }
    
    #habitDetailView.show {
        transform: translateX(-50%) !important;
    }
    
    #habitDetailView.hiding {
        transform: translateX(-50%) translateX(100%) !important;
    }
    
    /* Border radius for desktop view */
    #habitDetailView .position-sticky {
        border-radius: 15px 15px 0 0 !important;
    }
}

/* Custom Tab Navigation - Completely redesigned */
#habitTabs {
    display: flex;
    width: 100%;
    background-color: #fff;
    padding: 0;
    margin: 0 0 20px 0;
    border-bottom: 1px solid #eee;
    position: relative;
}

#habitTabs::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50%;
    height: 3px;
    background-color: var(--accent-color);
    transition: transform 0.3s ease;
    transform-origin: left center;
}

#habitTabs.statistics-active::after {
    transform: translateX(100%);
}

#habitTabs .nav-item {
    flex: 1;
}

#habitTabs .nav-link {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 5px;
    text-align: center;
    color: var(--font-color-light-gray);
    font-weight: 600;
    transition: all 0.3s ease;
    background-color: transparent;
    border: none;
    position: relative;
    border-radius: 0;
}

#habitTabs .nav-link.active {
    color: var(--accent-color);
    background-color: transparent;
}

/* Tab styling with clean approach */
.nav-tabs {
    border: none;
    margin-bottom: 20px;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: #777;
    transition: all 0.2s ease;
    background-color: transparent;
    border-radius: 0;
}

.nav-tabs .nav-link.active {
    border-bottom: 3px solid var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
}

.nav-tabs .nav-link:hover:not(.active) {
    border-bottom: 3px solid #eee;
}

/* Custom Day Indicators - Completely redesigned */
.current-week-section, 
.selected-days-section {
    margin-bottom: 30px;
}

.current-week-section h3,
.selected-days-section h3 {
    color: var(--font-color-dark-gray);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
}

/* Clean modern section headers */
.section-title {
    color: var(--font-color-dark-gray);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
    padding-left: 8px;
    border-left: 3px solid var(--primary-color);
}

/* Container for day indicators */
.days-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Clean day indicators layout */
.days-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.day-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.day-label {
    font-size: 12px;
    color: var(--font-color-light-gray);
    margin-bottom: 8px;
    font-weight: 500;
}

/* Base day indicator style */
.day-indicator {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Day indicator states */
.day-indicator.completed {
    background-color: var(--primary-color);
    color: white;
}

.day-indicator.missed {
    background-color: #e0e0e0;
    color: #909090;
}

.day-indicator.selected {
    background-color: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.day-indicator.upcoming {
    background-color: #f7f7f7;
    color: #888888;
    border: 1px solid #e0e0e0;
}

.day-indicator.inactive {
    background-color: white;
    border: 1px solid #e0e0e0;
    color: #cccccc;
}

.day-indicator.active {
    background-color: var(--font-color-black);
    color: white;
}

/* Day indicator interactions */
.day-indicator:hover:not(.inactive) {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.day-indicator:active:not(.inactive) {
    transform: scale(0.95);
}

/* Monthly Calendar styling - IMPROVED */
.calendar-container {
    margin-bottom: 25px;
    background-color: #ffffff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #f0f0f0;
    position: relative;
}

/* Calendar grid and day styling - FIXED to match design */
#calendarGrid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin: 10px 0;
}

#calendarGrid .col {
    aspect-ratio: 1/1;
    text-align: center;
    position: relative;
    padding: 2px;
}

/* Fixed calendar circle styles to match the screenshot */
.calendar-day {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    border-radius: 50%;
    margin: 0 auto;
    transition: all 0.2s ease;
}

/* Calendar day states with fixed styling to match screenshot */
.calendar-day.completed {
    background-color: #9B59B6;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.calendar-day.completed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: rgba(0, 0, 0, 0.1);
}

.calendar-day.missed {
    background-color: #ccc;
    color: white;
    font-weight: 500;
    box-shadow: none;
    position: relative;
}

.calendar-day.missed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 20%;
    width: 60%;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.7);
    transform: rotate(-10deg);
}

.calendar-day.today {
    background-color: white;
    border: 2px solid #9B59B6;
    color: #9B59B6;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 0 0 4px rgba(155, 89, 182, 0.3);
}

.calendar-day.prev-month,
.calendar-day.next-month {
    color: #ddd;
    opacity: 0.5;
    background-color: transparent;
}

/* Calendar day states */
.calendar-day.upcoming {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

/* Make calendar responsive on smaller screens */
@media (max-width: 400px) {
    .calendar-day {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

@media (max-width: 350px) {
    .calendar-day {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
}

/* Fix for statistics tab calendar scroll */
#statistics {
    overflow-x: hidden;
}

/* Calendar navigation styling */
.btn-outline-secondary.rounded-circle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: #e0e0e0;
    color: #757575;
    transition: all 0.2s ease;
}

.btn-outline-secondary.rounded-circle:hover {
    background-color: #f5f5f5;
    border-color: #d0d0d0;
    color: #424242;
}

/* Calendar legend styling - ensure proper display */
.calendar-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 0;
    margin-top: 15px;
    border-top: 1px solid #f5f5f5;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #757575;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Calendar month header styling */
.calendar-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.calendar-month-header h3 {
    font-size: 18px;
    margin: 0;
    color: #333;
}

.calendar-month-header .month-nav {
    display: flex;
    gap: 10px;
}

/* Day headers in calendar */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 500;
    color: #757575;
    margin-bottom: 10px;
    font-size: 13px;
}

/* Habit breakdown styling */
.habit-breakdown {
    background-color: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #f0f0f0;
    margin-top: 24px;
}

.habit-breakdown h4 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.habit-breakdown .progress {
    height: 10px;
    border-radius: 10px;
    background-color: #f0f0f0;
    overflow: hidden;
    margin-bottom: 10px;
}

.habit-breakdown .progress-bar {
    border-radius: 10px;
    transition: width 1s ease-in-out;
}

.habit-breakdown .stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    text-align: center;
    margin-bottom: 20px;
}

.habit-breakdown .stat-item {
    padding: 15px 5px;
    border-radius: 10px;
    background-color: #f9f9f9;
    transition: all 0.2s ease;
}

.habit-breakdown .stat-item:hover {
    background-color: #f5f5f5;
    transform: translateY(-2px);
}

.habit-breakdown .stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #333;
    transition: all 0.5s ease-out;
}

.habit-breakdown .stat-label {
    font-size: 12px;
    color: #757575;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Badge styling */
.habit-breakdown .badge {
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 20px;
}

/* Loading animation for statistics */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Skeleton loader for content that's loading */
.skeleton-loader {
    display: block;
    width: 100%;
    height: 20px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

/* Custom spinner size for statistics loading */
#statsLoadingIndicator .spinner-border,
#calendarGrid .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    animation: pulse 1.5s infinite, spinner-border 0.75s linear infinite;
}

/* Error state styling */
.text-danger i {
    animation: pulse 2s infinite;
}

/* Loading animation for statistics */
#statsLoadingIndicator .spinner-border {
    animation: pulse 1.5s infinite, spinner-border 0.75s linear infinite;
}

/* Statistics Tab Styling */
#statistics-tab {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

/* Calendar box container */
.calendar-box {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    padding: 15px;
    margin-bottom: 20px;
}

/* Day circles in detail view - improved responsive styles */
#habitDetailView .habit-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* Use flex instead of fixed min-width for better responsiveness */
    flex: 1;
    min-width: 0; /* Allow shrinking below content size if needed */
    padding: 0 1px;
}

#habitDetailView .day {
    font-size: 0.7rem;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: 500;
    white-space: nowrap;
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis; /* Handle long day names */
}

#habitDetailView .circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    box-sizing: border-box;
    margin: 0 auto;
}

/* Responsive adjustments for the circles */
@media (max-width: 360px) {
    #habitDetailView .circle {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    #habitDetailView .day {
        font-size: 0.6rem;
        margin-bottom: 3px;
    }
}

/* For larger screens */
@media (min-width: 400px) {
    #habitDetailView .circle {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
}

/* Adjust containers in detail view to use full width */
#habitDetailView .d-flex.justify-content-between {
    width: 100%;
    justify-content: space-between;
}

/* Day circles in detail view - match home page styling */
#habitDetailView .habit-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 1px;
    min-width: 38px;
    text-align: center;
}

#habitDetailView .day {
    font-size: 0.7rem;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: 500;
    white-space: nowrap;
    width: 100%;
    text-align: center;
}

#habitDetailView .circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    box-sizing: border-box;
    margin: 0 auto;
}

/* Calendar day status styles */
#calendarGrid .completed {
    background-color: #9B59B6; /* Meditation color from screenshot */
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#calendarGrid .missed {
    background-color: #ccc !important;
    color: white !important;
    box-shadow: none;
    position: relative;
}

#calendarGrid .today {
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.3);
}

#calendarGrid .future {
    opacity: 0.8;
}

#calendarGrid .selected {
    border: 2px solid #9B59B6;
    color: #9B59B6;
    background-color: white !important;
}

#calendarGrid .upcoming {
    opacity: 0.7;
}

/* Interactive hover effects */
@media (hover: hover) {
    #habitDetailView .circle:hover,
    #calendarGrid .small.rounded-circle:hover {
        transform: scale(1.05);
        cursor: pointer;
    }
}

#habitDetailView .circle:active,
#calendarGrid .small.rounded-circle:active {
    transform: scale(0.95);
}

/* Tab styling */
#habitDetailView .tab-navigation {
    border-bottom: 1px solid #dee2e6;
}

#habitDetailView .nav-link {
    color: #6c757d;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid transparent;
}

#habitDetailView .nav-link.active {
    color: #000;
    border-bottom: 2px solid #0d6efd;
}

/* Section Styling */
#habitDetailView h3.fw-bold {
    font-size: 1rem;
    margin-bottom: 15px;
}

/* Clean up any spacing issues */
#habitDetailView .tab-pane {
    padding-bottom: 80px; /* Room for the navbar at bottom */
}
