/* Custom styles for I Did a Thing! */

/* CSS Custom Properties for dynamic colors */
:root {
    --calendar-color: #28a745;
    --primary-color: #0d6efd; /* Default Bootstrap primary */
    --primary-light: #6ea8fe;
    --primary-dark: #0a58ca;
    --primary-very-light: #cfe2ff;
}

/* Toggle Button Styles */
.toggle-button {
    width: 200px;
    height: 200px;
    font-size: 1.5rem;
    font-weight: bold;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
}

.toggle-button:hover {
    transform: scale(1.05);
    border-color: var(--primary-dark) !important;
    color: var(--primary-dark) !important;
    background-color: var(--primary-very-light) !important;
}

/* Enhanced active button with fun whimsical design */
.toggle-button.active {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-light));
    color: white !important;
    border: 4px solid transparent;
    position: relative;
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
}

.toggle-button.active .toggle-text {
    color: white !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-button.active::before {
    content: '✨';
    position: absolute;
    top: -10px;
    left: -10px;
    font-size: 1.5rem;
    animation: sparkle 1s ease-in-out infinite alternate;
}

.toggle-button.active::after {
    content: '🎉';
    position: absolute;
    bottom: -10px;
    right: -10px;
    font-size: 1.5rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes sparkle {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.7;
    }
    100% {
        transform: rotate(180deg) scale(1.3);
        opacity: 1;
    }
}

@keyframes rainbowPulse {
    0% {
        box-shadow: 0 0 20px #ff6b6b, 0 0 40px #4ecdc4, 0 0 60px #45b7d1;
    }
    33% {
        box-shadow: 0 0 20px #feca57, 0 0 40px #ff9ff3, 0 0 60px #54a0ff;
    }
    66% {
        box-shadow: 0 0 20px #5f27cd, 0 0 40px #00d2d3, 0 0 60px #ff9ff3;
    }
    100% {
        box-shadow: 0 0 20px #ff6b6b, 0 0 40px #4ecdc4, 0 0 60px #45b7d1;
    }
}

/* Pulse animation for active state */
.toggle-button.active {
    animation: rainbowPulse 2s ease-in-out infinite;
}

/* Navbar theming */
.navbar-dark.bg-primary {
    background-color: var(--primary-color) !important;
}

.navbar-dark .navbar-brand:hover,
.navbar-dark .navbar-brand:focus {
    color: rgba(255, 255, 255, 0.9);
}

.navbar-dark .navbar-nav .nav-link.active {
    background-color: var(--primary-dark);
    border-radius: 0.375rem;
}

/* Calendar Tabs Styles with dynamic theming */
.nav-tabs {
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-light);
}

.nav-tabs .nav-link {
    color: #495057;
    border: 1px solid transparent;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    /* Ensure enough padding for the dot to be fully visible */
    padding-left: 1.2rem;
}

.nav-tabs .nav-link:hover {
    border-color: var(--primary-light) var(--primary-light) var(--primary-light);
    color: var(--primary-color);
    background-color: var(--primary-very-light);
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    background-color: #fff;
    border-color: var(--primary-light) var(--primary-light) #fff;
    font-weight: 600;
}

.nav-tabs .nav-link .calendar-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    /* Ensure dot doesn't get cut off */
    margin-left: -2px;
}

/* Text truncation for tab names */
.nav-tabs .nav-link {
    max-width: 150px;
    text-overflow: ellipsis;
    overflow: visible; /* Changed from hidden to visible for dot */
    white-space: nowrap;
}

/* Calendar Header with Edit Button */
.calendar-header-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.calendar-header-section h2 {
    margin: 0;
    color: var(--primary-color);
}

.edit-calendar-btn {
    background: none;
    border: 1px solid var(--primary-light);
    color: var(--primary-color);
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.edit-calendar-btn:hover {
    color: var(--primary-dark);
    background-color: var(--primary-very-light);
    border-color: var(--primary-color);
}

/* Calendar Card theming */
.card-header.bg-primary {
    background-color: var(--primary-color) !important;
    border-bottom-color: var(--primary-dark);
}

.card {
    border-color: var(--primary-light);
}

/* Calendar navigation buttons */
.btn-outline-light:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Calendar Styles */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: var(--primary-light);
    border: 1px solid var(--primary-light);
}

.calendar-header {
    background-color: var(--primary-very-light);
    padding: 10px;
    text-align: center;
    font-weight: bold;
    border: 1px solid var(--primary-light);
    color: var(--primary-color);
}

.calendar-day {
    background-color: white;
    padding: 15px 5px;
    text-align: center;
    position: relative;
    min-height: 60px;
    border: 1px solid var(--primary-light);
    cursor: default;
    transition: all 0.2s ease;
}

.calendar-day:hover {
    background-color: var(--primary-very-light);
}

.calendar-day.other-month {
    color: #6c757d;
    background-color: #f8f9fa;
}

.calendar-day.today {
    background: linear-gradient(135deg, var(--primary-very-light), rgba(255, 255, 255, 0.9));
    border: 3px solid var(--primary-color);
    font-weight: bold;
    color: var(--primary-dark);
    position: relative;
    transform: scale(1.05);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(var(--primary-color), 0.1),
        inset 0 2px 4px rgba(255, 255, 255, 0.7);
    animation: todayGlow 3s ease-in-out infinite;
}

/* Pulsing glow animation for today's date */
@keyframes todayGlow {
    0%, 100% {
        box-shadow:
            0 4px 12px rgba(0, 0, 0, 0.15),
            0 0 0 3px rgba(13, 110, 253, 0.1),
            0 0 15px rgba(13, 110, 253, 0.3),
            inset 0 2px 4px rgba(255, 255, 255, 0.7);
    }
    50% {
        box-shadow:
            0 6px 16px rgba(0, 0, 0, 0.2),
            0 0 0 5px rgba(13, 110, 253, 0.2),
            0 0 25px rgba(13, 110, 253, 0.5),
            inset 0 2px 4px rgba(255, 255, 255, 0.8);
    }
}

/* Add a subtle "TODAY" indicator */
.calendar-day.today::before {
    content: '⭐';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.75rem;
    opacity: 0.8;
    animation: sparkleRotate 4s linear infinite;
}

@keyframes sparkleRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced hover effect for today */
.calendar-day.today:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, var(--primary-light), rgba(255, 255, 255, 0.95));
    animation-duration: 1.5s; /* Faster pulse on hover */
}

/* Dynamic color for completion dots using CSS custom property */
.calendar-day.completed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: var(--calendar-color);
    border-radius: 50%;
    margin-top: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Calendar day clickable styling */
.calendar-day:not(.other-month) {
    cursor: pointer;
}

.calendar-day:not(.other-month):hover {
    background-color: var(--primary-very-light);
    transform: scale(1.02);
}

/* Stats display styling */
.stats-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.9), var(--primary-very-light));
    border-radius: 0.75rem;
    border: 2px solid var(--primary-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stats-section h5 {
    color: var(--primary-dark);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

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

.stat-card {
    text-align: center;
    padding: 1.25rem;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 0.5rem;
    border: 1px solid var(--primary-light);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.stat-card.collecting-data {
    opacity: 0.6;
    background: linear-gradient(145deg, #f8f9fa, #e9ecef);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    display: block;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.stat-card.collecting-data .stat-number {
    color: #6c757d;
    font-size: 1rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--primary-dark);
    margin-top: 0.25rem;
    font-weight: 600;
}

.stat-card.collecting-data .stat-label {
    color: #6c757d;
}

.stat-message {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-top: 0.5rem;
    font-style: italic;
}

.stat-card.collecting-data .stat-message {
    color: #6c757d;
}

/* Delete button styling */
.delete-calendar-btn {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.delete-calendar-btn:hover {
    background-color: #dc3545;
    color: white;
}

/* Modal Styles with theming */
.modal-header {
    background-color: var(--primary-very-light);
    border-bottom: 1px solid var(--primary-light);
}

.modal-title {
    color: var(--primary-color);
}

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

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

.btn-primary:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-color), 0.25);
}

.color-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-input-group input[type="color"] {
    width: 50px;
    height: 38px;
    border: 1px solid var(--primary-light);
    border-radius: 0.375rem;
    padding: 0;
    cursor: pointer;
}

.color-input-group input[type="text"] {
    font-family: monospace;
    text-transform: uppercase;
    border-color: var(--primary-light);
}

.color-input-group input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-color), 0.25);
}

/* Form validation styles */
.was-validated .form-control:valid {
    border-color: var(--primary-color);
}

.was-validated .form-control:invalid {
    border-color: #dc3545;
}

/* Links and interactive elements */
a {
    color: var(--primary-color);
}

a:hover {
    color: var(--primary-dark);
}

/* Footer theming */
.bg-light {
    background-color: var(--primary-very-light) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .toggle-button {
        width: 150px;
        height: 150px;
        font-size: 1.2rem;
    }

    .calendar-day {
        padding: 10px 2px;
        min-height: 50px;
        font-size: 0.9rem;
    }

    .nav-tabs .nav-link {
        max-width: 120px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .calendar-header-section {
        flex-direction: column;
        align-items: flex-start;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

@media (max-width: 576px) {
    .toggle-button {
        width: 120px;
        height: 120px;
        font-size: 1rem;
    }

    .calendar-day {
        padding: 8px 1px;
        min-height: 40px;
        font-size: 0.8rem;
    }

    .nav-tabs .nav-link {
        max-width: 100px;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .nav-tabs .nav-link .calendar-dot {
        width: 8px;
        height: 8px;
    }

    .color-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-number {
        font-size: 1.5rem;
    }
}

/* Loading animation */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Success animation */
@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-20px);
    }
    80% {
        transform: translateY(-10px);
    }
}

.bounce {
    animation: bounce 1s;
}

/* Tab overflow handling for many calendars */
.nav-tabs {
    flex-wrap: wrap;
}

/* Focus states for accessibility */
.nav-tabs .nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.edit-calendar-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Inline edit styles */
.calendar-header-section input.form-control {
    display: inline-block;
    width: auto;
    min-width: 200px;
    margin: 0;
    border-color: var(--primary-light);
}

.calendar-header-section input.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-color), 0.25);
}

/* Add calendar button styling */
#addCalendarBtn {
    border: 2px dashed var(--primary-light) !important;
    color: var(--primary-color);
    background-color: transparent;
}

#addCalendarBtn:hover {
    border-color: var(--primary-color) !important;
    color: var(--primary-dark);
    background-color: var(--primary-very-light);
}

/* Error message styling for future days */
.error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #dc3545;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1060;
    font-weight: 500;
    opacity: 0;
    animation: slideIn 0.3s ease forwards;
}

.error-message.fade-out {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}
