/* Custom Styles & Overrides */

/* Glassmorphism Utilities */
.glass-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.dark .glass-header {
    background: rgba(17, 24, 39, 0.8);
}

.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.dark .glass-card {
    background: rgba(31, 41, 55, 0.7);
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 20px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(75, 85, 99, 0.5);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(107, 114, 128, 0.8);
}

/* Drag & Drop Styles (SortableJS) */
.sortable-ghost {
    opacity: 0.4;
    background-color: #f3f4f6;
    border: 2px dashed #9ca3af;
    border-radius: 0.5rem;
}

.dark .sortable-ghost {
    background-color: #374151;
    border-color: #6b7280;
}

.sortable-drag {
    cursor: grabbing !important;
    opacity: 1 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    transform: scale(1.02);
}

.slot-container {
    min-height: 80px;
    transition: background-color 0.2s ease;
    position: relative;
}

.slot-container.drag-over {
    background-color: rgba(59, 130, 246, 0.1);
}

.dark .slot-container.drag-over {
    background-color: rgba(59, 130, 246, 0.2);
}

/* Empty cell hover effect */
.slot-container:empty::before {
    content: 'Click to add';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #9ca3af;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.dark .slot-container:empty::before {
    color: #6b7280;
}

.slot-container:empty:hover {
    background-color: rgba(59, 130, 246, 0.05);
    cursor: pointer;
}

.dark .slot-container:empty:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.slot-container:empty:hover::before {
    opacity: 1;
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    /* Hide everything except the app section */
    header, footer, #hero, #features, #templates, #faq, #toast, #periodModal {
        display: none !important;
    }
    /* Hide the toolbar inside the app section */
    #app .glass-card {
        display: none !important;
    }
    /* Make the app container take the full page */
    #app {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }
    /* Force the grid wrapper to fill the printed page and remove styling */
    #timetableWrapper {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }
    .overflow-x-auto {
        overflow: visible !important;
    }
    .slot-container {
        border: 1px solid #e5e7eb !important;
        break-inside: avoid;
        overflow: visible !important; /* Show all content in print */
        min-height: auto !important; /* Allow natural height */
    }
    
    /* Ensure period cards are fully visible */
    .slot-container > div {
        overflow: visible !important;
        white-space: normal !important;
    }
    /* Ensure colors are printed */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Fix grid alignment for mobile */
    #timetableBody > div {
        display: grid !important;
        grid-template-columns: 80px repeat(auto-fit, minmax(100px, 1fr)) !important;
    }
    
    /* Fix header alignment for mobile */
    #timetableWrapper > div:first-child {
        display: grid !important;
        grid-template-columns: 80px repeat(auto-fit, minmax(100px, 1fr)) !important;
    }
    
    /* Ensure cells align properly */
    .slot-container {
        min-width: 100px;
        padding: 0.5rem;
    }
    
    /* Time column styling */
    #timetableBody > div > div:first-child {
        min-width: 80px;
        max-width: 80px;
    }
    
    /* Day header styling */
    .day-col-header {
        min-width: 100px;
        font-size: 0.875rem;
        padding: 0.75rem 0.5rem;
    }
    
    /* Reduce font sizes for better fit */
    .slot-container .font-bold {
        font-size: 0.75rem;
    }
    
    .slot-container .text-xs {
        font-size: 0.625rem;
    }
}

/* Tooltip */
.tooltip-trigger {
    position: relative;
}

.tooltip-trigger::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background-color: #1f2937;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 50;
}

.dark .tooltip-trigger::after {
    background-color: #f9fafb;
    color: #111827;
}

.tooltip-trigger:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}
