/**
 * QR Code History Styles
 *
 * To remove this feature:
 * Simply remove the <link> tag referencing this CSS file from index.php
 */

/* History Panel */
.history-panel {
    padding: 20px;
}

/* History Controls */
.history-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.history-search-bar {
    display: flex;
    gap: 10px;
}

.history-search-bar input {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.history-search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.history-search-bar input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.history-search-bar select {
    min-width: 150px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding: 12px 35px 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-search-bar select:hover {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.02);
}

.history-search-bar select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.history-action-buttons {
    display: flex;
    gap: 10px;
}

/* History Stats */
.history-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.history-stat-card {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.history-stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.history-stat-card .stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* History Grid - Grid layout (5 columns desktop, 2 mobile) */
.history-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

/* Tablet: 3 columns */
@media (max-width: 1200px) {
    .history-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile: 2 columns */
@media (max-width: 768px) {
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small mobile: 1 column */
@media (max-width: 480px) {
    .history-grid {
        grid-template-columns: 1fr;
    }
}

/* History Card */
.history-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.history-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.history-qr-preview {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.history-qr-preview::before {
    display: none;
}

.history-qr-preview::after {
    display: none;
}

.history-qr-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.history-info {
    padding: 15px;
    flex: 1;
}

.history-type {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.history-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.format-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Code Type Badge (QR Code / Barcode indicator) */
.code-type-badge {
    position: absolute;
    top: 25px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 15;
}

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

.barcode-badge {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.no-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    color: var(--text-secondary);
}

.no-preview i {
    font-size: 48px;
    color: var(--primary-color);
    opacity: 0.5;
}

.no-preview span {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.history-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-meta i {
    font-size: 12px;
}

.history-actions {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* History Empty State */
.history-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.history-empty h3 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.history-empty p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Button Icons */
.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 16px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-primary);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-icon.btn-danger:hover {
    color: var(--danger-color);
}

/* Hidden File Input */
#history-import-file {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .history-controls {
        grid-template-columns: 1fr;
    }

    .history-search-bar {
        flex-direction: column;
    }

    .history-search-bar select {
        width: 100%;
    }

    .history-action-buttons {
        flex-wrap: wrap;
    }

    .history-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

/* Extra small mobile: KEEP 2 columns for better layout */
@media (max-width: 480px) {
    .history-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .history-stats {
        grid-template-columns: 1fr;
    }

    /* Reduce padding inside cards */
    .history-info {
        padding: 10px 8px !important;
    }

    /* Make card text smaller to prevent overflow */
    .history-name {
        font-size: 12px;
        line-height: 1.2;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .history-type {
        font-size: 9px;
        padding: 2px 5px;
    }

    .format-badge {
        font-size: 8px;
        padding: 2px 4px;
    }

    .history-meta {
        font-size: 10px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .history-meta span {
        font-size: 9px;
    }

    .history-meta i {
        font-size: 9px;
    }

    /* Smaller preview badge */
    .code-type-badge {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: 24px;
        right: 6px;
    }

    /* Smaller watermark */
    .history-qr-preview::after {
        font-size: 24px;
    }

    .history-qr-preview::before {
        font-size: 7px;
        padding: 2px 4px;
    }

    /* Reduce actions button size and center them */
    .history-actions {
        padding: 6px 8px !important;
        gap: 3px !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .btn-icon {
        font-size: 13px !important;
        padding: 6px !important;
    }
}

/* ============================================================ */
/* BACKEND VERSION - Card Grid Styles */
/* ============================================================ */

.history-item {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color, #e5e7eb);
    overflow: hidden;
}

.history-item:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transform: translateY(-4px);
}

.history-item-icon {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

.history-item-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.history-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.history-item-type {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    font-size: 15px;
}

.history-item-format {
    background: #e0e7ff;
    color: #4f46e5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.history-item-data {
    color: var(--text-secondary, #6b7280);
    font-size: 14px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary, #9ca3af);
    margin-top: auto;
}

.history-item-meta span {
    display: flex;
    align-items: center;
}

.history-item-meta i {
    margin-right: 5px;
}

.history-item-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    background: #f9fafb;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.history-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: white;
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.history-action-btn:hover {
    background: #f3f4f6;
    color: var(--primary-color, #4f46e5);
    border-color: var(--primary-color, #4f46e5);
    transform: translateY(-1px);
}

.history-action-btn.delete:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #dc2626;
}

/* Empty State */
.history-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #9ca3af);
}

.history-empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.history-empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--text-primary, #1f2937);
}

.history-empty-state p {
    font-size: 14px;
}
