/**
 * VisionLogic AI - History Page Stylesheet (MASTER FINAL VERSION)
 * VERSION: 1.4 (Added Mobile Responsive Card Layout)
 * FEATURES: Glassmorphism Tables, Action Popovers, Mobile Cards.
 * DESIGNER: DSON
 */

/* --- 1. TABLE LAYOUT & CARD EFFECT (Desktop Only) --- */
#historyTable {
    width: 100%;
}

@media (min-width: 768px) {
    #historyTable {
        border-separate: separate;
        border-spacing: 0 12px;
    }

    .history-row {
        background: rgba(255, 255, 255, 0.02);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .history-row:hover {
        background: rgba(255, 255, 255, 0.05);
        transform: translateY(-2px) scale(1.002);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }

    .history-row td {
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        transition: border-color 0.3s ease;
    }

    .history-row:hover td { border-color: rgba(0, 242, 254, 0.2); }
    .history-row td:first-child { border-left: 1px solid rgba(255, 255, 255, 0.05); border-radius: 1rem 0 0 1rem; }
    .history-row td:last-child { border-right: 1px solid rgba(255, 255, 255, 0.05); border-radius: 0 1rem 1rem 0; }
}

/* --- 2. STATUS BADGES --- */
.status-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.status-success { background: rgba(34, 197, 94, 0.1); color: #4ade80; }
.status-failed { background: rgba(239, 68, 68, 0.1); color: #f87171; }

/* --- 3. ACTION MENU (POPOVER) --- */
.history-row:has(.action-menu.active) { position: relative; z-index: 50 !important; }

.action-menu {
    display: none;
    position: absolute;
    right: 10%;
    top: 100%;
    margin-top: 8px;
    background: rgba(11, 14, 20, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 12px;
    width: 150px;
    z-index: 1000 !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.2s ease-out;
}
.action-menu.active { display: block; }

.action-item {
    padding: 12px 16px;
    width: 100%;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
}
.action-item:hover { background: rgba(0, 242, 254, 0.1); color: #00F2FE; }
.action-item.delete { color: #f87171; }

/* --- 4. FORM INPUTS (SCOPED TO HISTORY FILTERS ONLY) --- */
#typeFilter, #dateFilter { 
    outline: none; 
    font-family: inherit; 
    color-scheme: dark; 
    background-color: #111827 !important; 
    border: 1.5px solid #00F2FE !important; 
    color: white !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background-image: none !important;
}

#typeFilter:focus, #dateFilter:focus {
    border: 1.5px solid transparent !important;
    background-image: linear-gradient(#111827, #111827), 
                      linear-gradient(to right, #7064FF, #00F2FE) !important;
    background-origin: border-box !important;
    background-clip: padding-box, border-box !important;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.3);
}

input[type="date"]::-webkit-calendar-picker-indicator { 
    opacity: 0; 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    top: 0; left: 0; 
    cursor: pointer; 
}

/* --- 5. GLOBAL SYNC & RESPONSIVE --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.w-full.overflow-x-auto { overflow: visible !important; }

@media (min-width: 769px) {
    main {
        margin-left: calc(6rem - 1px) !important;
        border-left: 1px solid transparent;
    }
}

/* 💡 MOBILE MAGIC: Transform Table to Cards */
@media (max-width: 767px) {
    /* Hide the original table headers */
    #historyTable thead { display: none; }
    
    /* Make the table and tbody block level */
    #historyTable, #historyTable tbody { display: block; width: 100%; }

    /* Transform row into a card */
    .history-row {
        display: flex;
        flex-direction: column;
        background: rgba(31, 41, 55, 0.4) !important;
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 24px;
        margin-bottom: 24px;
        padding: 20px;
        position: relative;
    }

    /* Transform cells into rows within the card */
    .history-row td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0 !important;
        border: none !important;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.08) !important;
        background: transparent !important;
    }

    .history-row td:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    /* Inject data labels before the cell content */
    .history-row td::before {
        content: attr(data-label);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 2px;
        color: rgba(255, 255, 255, 0.4);
        font-weight: 700;
    }

    /* Thumbnail Cell Customization (Becomes a nice cover image on mobile) */
    .history-row td:nth-child(1) {
        justify-content: center;
        padding-top: 0 !important;
        border-bottom: none !important;
    }
    .history-row td:nth-child(1)::before { display: none; }
    .history-row td:nth-child(1) > div { 
        width: 100% !important; 
        height: 180px !important; 
        border-radius: 16px;
    }

    /* Align text to the right for values */
    .history-row td > span, .history-row td > button {
        text-align: right;
    }

    /* Fix action menu position on small screens */
    .action-menu {
        right: 0;
        top: auto;
        bottom: 100%;
        margin-bottom: 8px;
    }
}