/* ==============================================
   CRONBEATS - MAIN STYLESHEET
   ============================================== */

/* ==============================================
   COMMON STYLES - Used across all pages
   ============================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
    letter-spacing: -0.011em;
}

/* Modern Typography Utilities */
.tracking-tight-api { letter-spacing: -0.02em; }
.text-ui-label { 
    font-size: 0.8125rem; 
    font-weight: 500; 
    color: #64748b; /* slate-500 */
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.text-ui-value {
    font-size: 0.875rem;
    font-weight: 400;
    color: #1e293b; /* slate-800 */
}

/* Global responsive: prevent media and long text from breaking layout on mobile */
img, video, iframe, object, embed {
    max-width: 100%;
    height: auto;
}
pre, code {
    max-width: 100%;
    overflow-x: auto;
}
table {
    width: 100%;
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==============================================
   DASHBOARD STYLES
   ============================================== */

/* Tooltip Styles */
.tooltip-icon {
    position: relative;
    display: inline-flex;
}

.tooltip-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 50;
    pointer-events: none;
    animation: fadeIn 0.2s ease-in-out;
}

.tooltip-icon:hover::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
    z-index: 50;
    pointer-events: none;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Jobs Table - Base Styles */
#jobs-table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

#jobs-table thead {
    background-color: #4b5563;
}

#jobs-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s ease;
}

#jobs-table tbody tr:last-child {
    border-bottom: none;
}

#jobs-table tbody tr:hover {
    background-color: #fafafa;
}

/* Status indicator dot */
.status-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.status-dot.healthy { background-color: #10b981; }
.status-dot.down { background-color: #ef4444; }
.status-dot.grace { background-color: #f59e0b; }
.status-dot.waiting { background-color: #9ca3af; }

/* Prevent overflow on all elements */
#jobs-table td, #jobs-table th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#jobs-table td:first-child,
#jobs-table th:first-child {
    white-space: normal;
}

/* Actions column: right-align icon group on desktop */
#jobs-table td:nth-child(7) {
    text-align: right;
}
/* Remove tooltip (black block) on hover for action icons - keeps hover icon styles only */
#jobs-table .job-actions .tooltip-icon:hover::before,
#jobs-table .job-actions .tooltip-icon:hover::after {
    display: none !important;
}
#jobs-table .job-actions {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

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

/* Desktop Large (1536px and up) - Full table, all columns */


/* Mobile & Tablet (< 1024px) - Card layout when sidebar is hidden */
@media (max-width: 1023px) {
    /* Hide tooltips on mobile */
    .tooltip-icon:hover::after,
    .tooltip-icon:hover::before {
        display: none !important;
    }
    
    /* Hide table, show card grid */
    #jobs-table {
        display: block !important;
    }
    
    #jobs-table thead {
        display: none !important;
    }
    
    /* Card container - Grid layout for multiple cards per row */
    #jobs-table tbody {
        display: grid !important;
        gap: 1rem;
        grid-template-columns: 1fr; /* Default: 1 card per row for mobile portrait */
        padding: 0 1rem !important;
        margin: 0 !important;
        background: transparent !important;
        border: none !important;
    }
    
    /* Each card */
    #jobs-table tbody tr {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto auto auto;
        gap: 0.875rem 1.25rem;
        margin: 0 !important;
        padding: 1.25rem !important;
        padding-bottom: 0.75rem !important;
        background: white !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 0.75rem !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    #jobs-table tbody tr:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-color: #d1d5db;
        transform: translateY(-2px);
    }
    
    /* All data cells */
    #jobs-table tbody td {
        display: flex !important;
        flex-direction: column;
        gap: 0.375rem;
        padding: 0;
        border: none;
        white-space: normal;
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    /* Job Name - Row 1, full width */
    #jobs-table tbody td:nth-child(1) {
        grid-column: 1 / -1;
        grid-row: 1;
        font-size: 1.125rem;
        font-weight: 700;
        color: #111827;
        padding-bottom: 0.875rem;
        border-bottom: 2px solid #f3f4f6;
        margin-bottom: 0.25rem;
    }
    
    /* Last Ping / Next Run - Row 2, split into two clear blocks */
    #jobs-table tbody td:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        align-items: start;
    }
    #jobs-table tbody td:nth-child(2)::before {
        display: none !important;
        content: '';
    }
    #jobs-table tbody td:nth-child(2) .job-last-ping {
        margin-top: 0;
        font-size: 0.95rem;
        color: #111827;
        font-weight: 600;
        display: block;
    }
    #jobs-table tbody td:nth-child(2) .job-next-run {
        font-size: 0.8rem;
        color: #4b5563;
        display: block;
    }
    #jobs-table tbody td:nth-child(2) .job-last-ping::before,
    #jobs-table tbody td:nth-child(2) .job-next-run::before {
        display: block;
        margin-bottom: 0.2rem;
        font-weight: 600;
        color: #9ca3af;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    #jobs-table tbody td:nth-child(2) .job-last-ping::before {
        content: 'LAST PING';
    }
    #jobs-table tbody td:nth-child(2) .job-next-run::before {
        content: 'NEXT RUN';
    }

    /* Progress - Row 3, full width */
    #jobs-table tbody td:nth-child(3) {
        grid-column: 1 / -1;
        grid-row: 3;
    }
    #jobs-table tbody td:nth-child(3)::before {
        content: 'PROGRESS';
        font-weight: 600;
        color: #9ca3af;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* Actions - Row 4, full width */
    #jobs-table tbody td:nth-child(4) {
        grid-column: 1 / -1;
        grid-row: 4;
        display: flex !important;
        flex-direction: row !important;
        gap: 0.5rem;
        justify-content: flex-end;
        align-items: center;
        padding-top: 0.5rem;
        margin-top: -0.25rem;
    }
    #jobs-table tbody td:nth-child(4) a,
    #jobs-table tbody td:nth-child(4) button {
        padding: 0.5rem;
        width: 36px;
        height: 36px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
}

/* Responsive Card Grid - Mobile Landscape (568px - 899px) - 2 cards per row */
@media (min-width: 568px) and (max-width: 899px) {
    #jobs-table tbody {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Responsive Card Grid - Landscape Tablet (900px - 1023px) - 3 cards per row */
@media (min-width: 900px) and (max-width: 1023px) {
    #jobs-table tbody {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ==============================================
   ALERTS PAGE - 3 COLUMNS ON MOBILE, % WIDTHS FOR RESPONSIVE
   ============================================== */
#alerts-table {
    table-layout: fixed;
    width: 100%;
}
/* Desktop: 6 columns with % widths */
#alerts-table th:nth-child(1),
#alerts-table td:nth-child(1) { width: 18%; }
#alerts-table th:nth-child(2),
#alerts-table td:nth-child(2) { width: 12%; }
#alerts-table th:nth-child(3),
#alerts-table td:nth-child(3) { width: 14%; }
#alerts-table th:nth-child(4),
#alerts-table td:nth-child(4) { width: 28%; }
#alerts-table th:nth-child(5),
#alerts-table td:nth-child(5) { width: 12%; }
#alerts-table th:nth-child(6),
#alerts-table td:nth-child(6) { width: 16%; }

@media (max-width: 767px) {
    #alerts-table {
        font-size: 0.875rem;
        table-layout: auto;
    }
    #alerts-table th,
    #alerts-table td {
        padding: 0.75rem 0.5rem;
    }
    /* No fixed column widths on mobile — columns size naturally; job name wraps */
    #alerts-table th:nth-child(1),
    #alerts-table td:nth-child(1) { white-space: normal; word-break: break-word; }
    #alerts-table th:nth-child(2),
    #alerts-table td:nth-child(2) { white-space: normal; }
    #alerts-table th:first-child,
    #alerts-table td:first-child {
        padding-left: 1rem;
    }
    #alerts-table th:last-child,
    #alerts-table td:last-child {
        padding-right: 1rem;
    }
    /* Hide Time column on mobile - time is shown below Type */
    #alerts-table thead th:nth-child(6),
    #alerts-table tbody td:nth-child(6) {
        display: none !important;
    }
}

/* ==============================================
   JOB SETUP PAGE - RESPONSIVE
   ============================================== */
.job-setup-page pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-all;
    white-space: pre-wrap;
}
.job-setup-page pre code {
    word-break: break-all;
    white-space: pre-wrap;
}
.job-setup-page .bg-gray-900 .flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: 0.5rem;
}
.job-setup-page .bg-gray-900 button {
    min-height: 36px;
    min-width: 44px;
}
@media (max-width: 640px) {
    .job-setup-page .bg-gray-900 {
        padding: 0.75rem 1rem;
    }
    .job-setup-page .bg-gray-900 pre {
        font-size: 0.75rem;
    }
}

/* ==============================================
   HOME PAGE / LANDING PAGE STYLES
   ============================================== */

.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-border {
    border-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%) 1;
}

.pulse-dot {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

.fade-in-up {
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.ai-glow {
    box-shadow: 0 0 40px rgba(102, 126, 234, 0.3);
}

/* ==============================================
   AUTH / INVITATION PAGES
   ============================================== */

.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.card-shadow {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

/* ==============================================
   ADMIN PANEL STYLES
   ============================================== */

/* Compact scrollbar for admin panel */
.admin-layout ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.admin-layout ::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.admin-layout ::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.admin-layout ::-webkit-scrollbar-thumb:hover {
    background: #555;
}
