/**
 * Label System CSS for Resto M2 Plugin
 * Version: 1.0.0
 */

/* Label Grid Layout */
.labels-grid,
.custom-labels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Label Card Styles */
.label-card {
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    overflow: hidden;
    background: white;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.label-card:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px);
}

/* Label Preview */
.label-preview {
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.label-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.label-badge i {
    font-size: 14px;
}

/* Label Style Variants */
.label-style-badges .resto-label {
    border-radius: 6px;
}

.label-style-pills .resto-label {
    border-radius: 20px;
}

.label-style-tags .resto-label {
    border-radius: 4px;
    position: relative;
    padding-left: 20px;
}

.label-style-tags .resto-label::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    opacity: 0.8;
}

.label-style-minimal .resto-label {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(4px);
    border: 1px solid currentColor;
    color: inherit;
    box-shadow: none;
}

/* Label Info */
.label-info {
    padding: 24px;
}

.label-info h4 {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.label-info p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.label-actions {
    padding: 0 24px 24px;
    display: flex;
    gap: 10px;
}

.label-actions .button {
    flex: 1;
    justify-content: center;
}

/* Custom Label Actions */
.custom-label-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.custom-label-actions .button {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* No Custom Labels */
.no-custom-labels {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    color: #666;
}

/* Label Modal */
.resto-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.resto-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.resto-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
}

.resto-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.resto-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.resto-modal-close:hover {
    background: #f8f9fa;
}

.resto-modal-body {
    padding: 25px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.form-group input[type="color"] {
    height: 45px;
    padding: 2px;
    cursor: pointer;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Modal Label Preview */
.modal-label-preview {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* Item Labels Positioning */
.resto-item-labels {
    position: absolute;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 10;
}

.resto-item-labels.label-position-top-left {
    top: 10px;
    left: 10px;
}

.resto-item-labels.label-position-top-right {
    top: 10px;
    right: 10px;
}

.resto-item-labels.label-position-bottom-left {
    bottom: 10px;
    left: 10px;
}

.resto-item-labels.label-position-bottom-right {
    bottom: 10px;
    right: 10px;
}

.resto-item-labels.label-position-below-title {
    position: static;
    margin-top: 8px;
}

/* Frontend Label Styles */
.resto-menu-item .resto-item-labels {
    position: absolute;
    z-index: 5;
}

.resto-menu-item .item-labels .label-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Label Animations */
.label-badge {
    animation: labelFadeIn 0.3s ease;
}

@keyframes labelFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.label-badge.slide {
    animation: labelSlideIn 0.3s ease;
}

@keyframes labelSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.label-badge.bounce {
    animation: labelBounceIn 0.5s ease;
}

@keyframes labelBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* System Label Categories */
.label-card.dietary .label-category {
    background: #d4edda;
    color: #155724;
}

.label-card.allergen .label-category {
    background: #f8d7da;
    color: #721c24;
}

.label-card.special .label-category {
    background: #d1ecf1;
    color: #0c5460;
}

.label-card.promotion .label-category {
    background: #fff3cd;
    color: #856404;
}

/* Responsive Design */
@media (max-width: 768px) {

    .labels-grid,
    .custom-labels-grid {
        grid-template-columns: 1fr;
    }

    .label-actions {
        flex-direction: column;
    }

    .custom-label-actions {
        flex-direction: column;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .resto-modal-content {
        width: 95%;
        margin: 10px;
    }

    .item-labels {
        flex-direction: column;
        gap: 4px;
    }

    .item-labels .label-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .label-card {
        background: #2d2d2d;
        border-color: #555;
    }

    .label-info h4 {
        color: #fff;
    }

    .label-info p {
        color: #ccc;
    }

    .label-preview {
        background: #3d3d3d;
        border-color: #555;
    }

    .resto-modal-content {
        background: #2d2d2d;
    }

    .resto-modal-header {
        border-color: #555;
    }

    .resto-modal-header h3 {
        color: #fff;
    }

    .form-group label {
        color: #ccc;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        background: #3d3d3d;
        border-color: #555;
        color: #fff;
    }

    .modal-label-preview {
        background: #3d3d3d;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .label-card {
        border-width: 3px;
    }

    .label-badge {
        border: 2px solid currentColor;
    }

    .assign-label,
    .edit-label,
    .delete-label {
        border-width: 2px;
    }
}

/* Print Styles */
@media print {

    .label-actions,
    .custom-label-actions,
    .resto-modal {
        display: none;
    }

    .label-card {
        break-inside: avoid;
        border: 1px solid #000;
    }

    .label-badge {
        border: 1px solid #000;
        color: #000 !important;
        background: transparent !important;
    }
}

/* Loading States */
.label-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.label-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 #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Accessibility */
.label-card:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.assign-label:focus,
.edit-label:focus,
.delete-label:focus {
    outline: 2px solid #007cba;
    outline-offset: 1px;
}

.label-badge:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Tooltip for labels */
.label-badge[title] {
    cursor: help;
}

/* Label count indicator */
.label-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* Label filter */
.label-filter {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.label-filter button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.label-filter button.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.label-filter button:hover {
    border-color: #007cba;
}