/* Custom styles for GLP3 Planner */

/* Modern font stack */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Table input styling */
#doseTable input[type="number"],
#doseTable input[type="time"],
#doseTable input[type="text"] {
    background-color: transparent;
    border: 1px solid transparent;
    transition: all 0.2s;
}

#doseTable input[type="number"]:hover,
#doseTable input[type="time"]:hover,
#doseTable input[type="text"]:hover {
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

#doseTable input[type="number"]:focus,
#doseTable input[type="time"]:focus,
#doseTable input[type="text"]:focus {
    background-color: white;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Dose list item styling */
.dose-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background-color: #f9fafb;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.dose-item:hover {
    background-color: #f3f4f6;
}

.dose-item button {
    opacity: 0;
    transition: opacity 0.2s;
}

.dose-item:hover button {
    opacity: 1;
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

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

/* Ensure Plotly plots clear spinners */
.js-plotly-plot {
    position: relative;
    z-index: 20;
}

/* Plot container styling */
#plotContainer, #weightPlotContainer {
    position: relative;
    background: linear-gradient(to bottom, rgba(248, 250, 252, 0.5), rgba(255, 255, 255, 0));
    border-radius: 0.5rem;
}

#plotContainer {
    min-height: 600px;
}

/* Modern card shadows */
.bg-white.rounded-lg.shadow-md {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s;
}

.bg-white.rounded-lg.shadow-md:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #plotContainer {
        min-height: 300px;
        height: 350px !important;
    }
    
    #weightPlotContainer {
        height: 200px !important;
    }
    
    /* Reduce padding on mobile */
    .bg-white.rounded-lg.shadow-md {
        padding: 1rem;
    }
    
    /* Smaller text on mobile */
    .text-xl {
        font-size: 1.125rem;
    }
    
    .text-lg {
        font-size: 1rem;
    }
    
    /* Compact statistics on mobile */
    #statistics {
        gap: 0.75rem;
    }
    
    #statistics > div {
        padding: 0.5rem;
    }
    
    #statistics p.text-sm {
        font-size: 0.75rem;
    }
    
    #statistics p.text-lg {
        font-size: 0.875rem;
    }
    
    /* Make modebar more visible on mobile */
    .modebar {
        background: rgba(255, 255, 255, 0.9) !important;
        border-radius: 4px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    /* Ensure charts don't overflow on small screens */
    .js-plotly-plot {
        max-width: 100%;
    }
    
    /* Adjust container padding for very small screens */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    #plotContainer {
        height: 300px !important;
    }
    
    /* Even smaller statistics text */
    #statistics p.text-sm {
        font-size: 0.625rem;
    }
    
    #statistics p.text-lg {
        font-size: 0.75rem;
    }
    
    /* Single column statistics on very small screens */
    #statistics {
        grid-template-columns: 1fr;
    }
}

/* Schedule card styling */
.schedule-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.schedule-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Button group styling */
.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.button-group button {
    flex: 1;
    min-width: 60px;
}

/* Message container */
#messageContainer {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Base message styling */
.flash-message {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    pointer-events: auto;
    animation: slideIn 0.3s ease-out;
    max-width: 90%;
    text-align: center;
}

/* Error message styling */
.error-message {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

/* Success message styling */
.success-message {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
}

/* Slide in animation */
@keyframes slideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Fade out animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.flash-message.removing {
    animation: fadeOut 0.3s ease-out forwards;
}

/* Mobile responsiveness */
@media (max-width: 767px) {
    /* Smaller buttons on mobile */
    .bg-red-500, .bg-gray-500, .bg-purple-500, .bg-green-500 {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Stack buttons on very small screens */
    @media (max-width: 480px) {
        .space-x-2 {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.5rem;
        }
    }
    
    /* Better touch targets for mobile inputs */
    input[type="number"],
    input[type="time"],
    textarea {
        min-height: 44px;
    }
    
    /* Mobile card hover states */
    #doseMobileView > div {
        transition: transform 0.1s ease-in-out;
    }
    
    #doseMobileView > div:active {
        transform: scale(0.98);
    }
}

/* Modal animations */
#generalModal, #doseContributionModal, #shareModal {
    transition: opacity 0.2s ease-out;
}

#generalModal.hidden, #doseContributionModal.hidden, #shareModal.hidden {
    opacity: 0;
    pointer-events: none;
}

#generalModal:not(.hidden), #doseContributionModal:not(.hidden), #shareModal:not(.hidden) {
    opacity: 1;
}

#generalModal > div:last-child,
#doseContributionModal > div:last-child,
#shareModal > div:last-child {
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

#generalModal.hidden > div:last-child,
#doseContributionModal.hidden > div:last-child,
#shareModal.hidden > div:last-child {
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
}

#generalModal:not(.hidden) > div:last-child,
#doseContributionModal:not(.hidden) > div:last-child,
#shareModal:not(.hidden) > div:last-child {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Login required field styling */
.login-required {
    background-color: #f9fafb !important;
    color: #6b7280 !important;
}

.login-required:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.login-required:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.3) !important;
    border-color: #9ca3af !important;
}

/* Local data indicator styling */
.bg-amber-50 {
    background-color: #fffbeb !important;
}


/* Construction Banner Styling */
#constructionBanner {
    /* Ensure it appears above most content but below message container */
    z-index: 40;
}

#constructionBanner.banner-hidden {
    transform: translateY(-100%);
}

/* Adjust message container position when banner is visible */
body.has-construction-banner #messageContainer {
    padding-top: 4rem; /* Adjust based on banner height */
}

/* Mobile adjustments for construction banner */
@media (max-width: 640px) {
    #constructionBanner p {
        font-size: 0.875rem;
    }
    
    #constructionBanner svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    body.has-construction-banner #messageContainer {
        padding-top: 3.5rem;
    }
}