/**
 * Admin Role-Based Styling
 * CSS for role-based UI elements and admin functionality
 */

/* Role-based visibility classes */
.admin-only,
.head-admin-only {
    display: none; /* Hidden by default, shown via JavaScript based on role */
}

/* Ensure admin toolbar buttons align properly when shown via JS */
#add-product-btn {
    display: none; /* default hidden; JS sets inline-flex for admins */
}

.user-only {
    display: none; /* Hidden by default, shown for regular users */
}

/* Role indicator styling */
.role-indicator {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    border: 1px solid;
}

.role-head-admin {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    border-color: #dc2626;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

.role-user {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border-color: #059669;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

.role-guest {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
    color: white;
    border-color: #6b7280;
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}

/* Edit button styling for product cards */
.product-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
    z-index: 10;
}

.product-edit-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.product-edit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.product-edit-btn i {
    margin-right: 4px;
}

/* Admin panel styling */
.admin-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none; /* Hidden by default */
}

.admin-panel-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Product card modifications for admin view */
.product-card {
    position: relative; /* Ensure edit button positioning works */
}

.product-card.admin-mode {
    border: 2px solid #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.product-card.admin-mode::before {
    content: "EDIT MODE";
    position: absolute;
    top: -1px;
    left: -1px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 4px 0 4px 0;
    z-index: 5;
}

/* Admin toolbar */
.admin-toolbar {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    border: 1px solid #e5e7eb;
}

.admin-toolbar h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.admin-toolbar-btn {
    display: block;
    width: 100%;
    margin-bottom: 4px;
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #374151;
    text-decoration: none;
    font-size: 12px;
    transition: all 0.2s ease;
}

.admin-toolbar-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.admin-toolbar-btn:last-child {
    margin-bottom: 0;
}

/* Success/Error messages for admin actions */
.admin-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    font-weight: 500;
    z-index: 1001;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.admin-message.show {
    opacity: 1;
    transform: translateX(0);
}

.admin-message.success {
    background: #d1fae5;
    border: 1px solid #10b981;
    color: #065f46;
}

.admin-message.error {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

.admin-message.warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}

/* Mobile responsiveness for admin elements */
@media (max-width: 768px) {
    .role-indicator {
        display: block;
        margin-left: 0;
        margin-top: 4px;
        font-size: 9px;
        padding: 2px 6px;
    }
    
    .admin-toolbar {
        top: 60px;
        right: 10px;
        left: 10px;
        width: auto;
    }
    
    .product-edit-btn {
        top: 4px;
        right: 4px;
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .admin-panel-content {
        margin: 20px;
        padding: 16px;
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 40px);
    }
}

/* Loading states for admin actions */
.admin-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.admin-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: admin-spin 1s linear infinite;
}

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

/* Admin badge for header */
.admin-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
    animation: admin-pulse 2s infinite;
}

@keyframes admin-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Edit mode overlay */
.edit-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.1);
    backdrop-filter: blur(1px);
    z-index: 1;
    pointer-events: none;
}

/* Hide edit buttons by default, show only for HEAD admins */
.product-edit-btn {
    display: none;
}

.head-admin-only .product-edit-btn {
    display: inline-block;
} 

/* Admin edit button in product content area */
.admin-edit-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    margin-bottom: 8px;
}

.admin-edit-btn {
    background-color: #dc2626;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.admin-edit-btn:hover {
    background-color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.admin-edit-btn i {
    margin-right: 2px;
}

/* Hide admin edit button by default, show only for HEAD admins */
.admin-edit-container {
    display: none;
}

body.admin-mode .admin-edit-container {
    display: flex;
} 