/**
 * LMS Certificate Manager - Frontend Styles (Mobile-First)
 * Location: /assets/css/frontend.css
 */

/* ========== Container ========== */
.lms-cert-frontend-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 15px;
}

/* ========== Header ========== */
.lms-cert-header {
    text-align: center;
    margin-bottom: 25px;
}

.lms-cert-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.lms-cert-header .cert-icon {
    font-size: 28px;
}

.lms-cert-header .cert-count {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* ========== Search ========== */
.cert-search-wrapper {
    position: relative;
    margin-bottom: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.cert-search {
    width: 100%;
    padding: 12px 40px 12px 15px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.3s;
}

.cert-search:focus {
    border-color: #FFD700;
}

.cert-search-clear {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: #ccc;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
}

/* ========== No Certificates State ========== */
.no-certs-state {
    text-align: center;
    padding: 60px 20px;
    background: #f9f9f9;
    border-radius: 12px;
    border: 2px dashed #ddd;
}

.no-cert-icon {
    font-size: 80px;
    margin-bottom: 15px;
}

.no-certs-state h3 {
    font-size: 22px;
    color: #333;
    margin: 15px 0 10px 0;
}

.no-certs-state p {
    color: #666;
    font-size: 15px;
    margin: 0;
}

/* ========== No Results ========== */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* ========== Certificate Cards Container ========== */
.cert-cards-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ========== Certificate Card ========== */
.cert-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    min-width: 320px;  /* Ensure cards have minimum width for proper display */
}

.cert-card:active {
    transform: scale(0.98);
}

/* ========== Card Header ========== */
.cert-card-header {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cert-badge {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.badge-icon {
    font-size: 36px;
}

.cert-status {
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.cert-status.active {
    color: #00a32a;
}

.cert-status.revoked {
    color: #d63638;
}

/* ========== Card Body ========== */
.cert-card-body {
    padding: 20px;
}

.cert-title {
    font-size: 18px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 15px 0;
    line-height: 1.4;
}

/* ========== Certificate Details ========== */
.cert-details {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.cert-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    gap: 15px;  /* Increased from 10px for better spacing */
}

.cert-detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.cert-detail-row:first-child {
    padding-top: 0;
}

.detail-label {
    font-size: 13px;
    color: #666;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 100px;  /* Ensure label has enough space */
}

.detail-value {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    text-align: right;
    flex: 1;  /* Take remaining space */
    overflow-wrap: break-word;  /* Better text wrapping */
}

.detail-value.cert-id {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;  /* Slightly larger for readability */
    white-space: nowrap;  /* Keep certificate ID on one line */
    overflow: hidden;  /* Hide overflow */
    text-overflow: ellipsis;  /* Show ... if too long */
    line-height: 1.4;  /* Better line spacing */
}

/* ========== Action Buttons ========== */
.cert-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.cert-action-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s;
}

.cert-action-btn .btn-icon {
    font-size: 24px;
}

.cert-action-btn .btn-text {
    font-size: 13px;
}

.btn-view {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #fff;
}

.btn-view:active {
    background: linear-gradient(135deg, #135e96 0%, #0a4a75 100%);
}

.btn-download {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

.btn-download:active {
    background: #e0e0e0;
}

/* ========== Modal ========== */
.cert-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cert-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.cert-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.cert-modal-close {
    position: sticky;
    top: 10px;
    right: 10px;
    float: right;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s;
}

.cert-modal-close:active {
    background: rgba(0, 0, 0, 0.2);
}

.cert-modal-body {
    padding: 30px 20px;
    clear: both;
}

/* ========== Modal Content ========== */
.cert-details-modal {
    text-align: center;
}

.modal-header {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-badge {
    font-size: 60px;
    margin-bottom: 10px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1d2327;
    margin: 0 0 5px 0;
}

.modal-subtitle {
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.modal-details {
    display: grid;
    gap: 12px;
    margin-bottom: 25px;
    text-align: left;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 15px;
    background: #f8f8f8;
    border-radius: 6px;
}

.item-label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.item-value {
    font-size: 15px;
    color: #333;
    font-weight: 500;
    word-break: break-word;
}

.item-value.cert-id {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-value.status-active {
    color: #00a32a;
    font-weight: 700;
}

.item-value.status-revoked {
    color: #d63638;
    font-weight: 700;
}

.modal-footer {
    text-align: center;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-footer .cert-action-btn {
    width: 100%;
}

@media (max-width: 480px) {
    .modal-footer {
        grid-template-columns: 1fr;
    }
}

/* ========== Loading Spinner ========== */
.loading {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: #666;
    font-size: 14px;
}

/* ========== Tablet & Desktop ========== */
@media (min-width: 768px) {
    .lms-cert-frontend-container {
        padding: 30px 20px;
    }
    
    .lms-cert-header h2 {
        font-size: 32px;
    }
    
    .cert-cards-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
    
    .cert-action-btn {
        flex-direction: row;
        gap: 8px;
    }
    
    .cert-action-btn .btn-text {
        font-size: 14px;
    }
    
    .cert-action-btn .btn-icon {
        font-size: 18px;
    }
    
    .cert-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }
}

@media (min-width: 1024px) {
    .cert-cards-container {
        grid-template-columns: repeat(2, 1fr);  /* Keep 2 columns for better readability */
        gap: 35px;
    }
    
    .lms-cert-frontend-container {
        padding: 40px 30px;
        max-width: 1400px;  /* Limit max width for better card size */
    }
}
