/* ===========================
   Code Image Manager - Public Styles
   Charte Graphique: #F39207 (orange) #009bb5 (cyan) #61A937 (vert) #82171B (marron)
   Police: Fira Sans Condensed
   =========================== */

/* Import Google Font - Fira Sans Condensed */
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans+Condensed:wght@300;400;500;600;700&display=swap');

* {
    font-family: 'Fira Sans Condensed', sans-serif;
}

.cim-public-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Header */
.cim-public-header {
    text-align: center;
    margin-bottom: 40px;
}

.cim-public-title {
    font-size: 36px;
    font-weight: 700;
    color: #82171B; /* Marron principal */
    margin: 0;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Search Box */
.cim-search-box {
    max-width: 650px;
    margin: 0 auto 50px;
}

.cim-public-form {
    position: relative;
}

.cim-input-group {
    display: flex;
    gap: 10px;
    box-shadow: 0 6px 25px rgba(130, 23, 27, 0.15);
    border-radius: 12px;
    overflow: hidden;
    background: white;
    border: 2px solid #82171B;
}

.cim-code-input {
    flex: 1;
    padding: 18px 24px;
    font-size: 17px;
    font-weight: 500;
    border: none;
    outline: none;
    transition: all 0.3s;
    background: transparent;
    color: #333;
}

.cim-code-input::placeholder {
    color: #999;
    font-weight: 400;
}

.cim-code-input:focus {
    background: #fff9f5;
}

.cim-submit-btn {
    padding: 18px 36px;
    background: linear-gradient(135deg, #82171B 0%, #5c1014 100%);
    color: white;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cim-submit-btn:hover {
    background: linear-gradient(135deg, #5c1014 0%, #82171B 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(130, 23, 27, 0.4);
}

.cim-submit-btn:active {
    transform: translateY(0);
}

/* Loading */
.cim-loading {
    text-align: center;
    padding: 60px 20px;
}

.cim-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 5px solid #f0f0f0;
    border-top: 5px solid #82171B;
    border-radius: 50%;
    animation: cim-spin 1s linear infinite;
}

@keyframes cim-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cim-loading p {
    color: #82171B;
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

/* Error Message */
.cim-error-message {
    max-width: 600px;
    margin: 40px auto;
    padding: 20px 24px;
    background: #fff5f5;
    border-left: 5px solid #82171B;
    border-radius: 8px;
    color: #82171B;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.6;
    box-shadow: 0 4px 15px rgba(130, 23, 27, 0.1);
}

/* Result Container */
.cim-result-container {
    animation: cim-fadeIn 0.6s ease-in;
}

@keyframes cim-fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Result Header */
.cim-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
    padding: 25px 30px;
    background: linear-gradient(135deg, #82171B 0%, #5c1014 100%);
    border-radius: 12px;
    color: white;
    box-shadow: 0 6px 20px rgba(130, 23, 27, 0.25);
}

.cim-image-count {
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cim-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cim-btn-primary {
    background: white;
    color: #82171B;
    border: 2px solid white;
}

.cim-btn-primary:hover {
    background: #F39207;
    color: white;
    border-color: #F39207;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(243, 146, 7, 0.4);
}

.cim-btn svg {
    width: 18px;
    height: 18px;
}

/* Gallery */
.cim-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 28px;
}

.cim-gallery-item {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(130, 23, 27, 0.1);
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.cim-gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 30px rgba(130, 23, 27, 0.2);
    border-color: #F39207;
}

.cim-image-wrapper {
    position: relative;
    padding-top: 75%;
    overflow: hidden;
    background: #f8f8f8;
}

.cim-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}

.cim-gallery-item:hover .cim-image-wrapper img {
    transform: scale(1.08);
}

.cim-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(130, 23, 27, 0.85) 0%, rgba(243, 146, 7, 0.85) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.cim-gallery-item:hover .cim-image-overlay {
    opacity: 1;
}

.cim-overlay-icon {
    width: 54px;
    height: 54px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #82171B;
    transform: scale(0.8);
    transition: transform 0.3s;
}

.cim-gallery-item:hover .cim-overlay-icon {
    transform: scale(1);
}

.cim-image-info {
    padding: 16px;
    background: #fafafa;
}

.cim-image-name {
    font-size: 15px;
    font-weight: 600;
    color: #82171B;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cim-image-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.cim-image-actions {
    padding: 0 16px 16px;
    background: #fafafa;
}

.cim-download-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #82171B 0%, #5c1014 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cim-download-btn:hover {
    background: linear-gradient(135deg, #F39207 0%, #d67f06 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(243, 146, 7, 0.4);
}

.cim-download-btn svg {
    width: 16px;
    height: 16px;
}

/* Lightbox */
.cim-lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(130, 23, 27, 0.95);
    backdrop-filter: blur(15px);
    animation: cim-fadeIn 0.3s;
}

.cim-lightbox-content {
    max-width: 90%;
    max-height: 90vh;
    margin: auto;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    box-shadow: 0 15px 60px rgba(0, 0, 0, 0.6);
    border: 3px solid #F39207;
}

.cim-lightbox-close {
    position: absolute;
    top: 25px;
    right: 45px;
    color: white;
    font-size: 45px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 146, 7, 0.3);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.cim-lightbox-close:hover {
    background: #F39207;
    border-color: #F39207;
    transform: rotate(90deg) scale(1.1);
}

.cim-lightbox-caption {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(130, 23, 27, 0.9);
    color: white;
    padding: 16px 35px;
    border-radius: 30px;
    font-size: 17px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    border: 2px solid #F39207;
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 768px) {
    .cim-public-title {
        font-size: 28px;
    }
    
    .cim-result-header {
        flex-direction: column;
        gap: 18px;
        text-align: center;
        padding: 20px;
    }
    
    .cim-gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 18px;
    }
    
    .cim-input-group {
        flex-direction: column;
        gap: 0;
    }
    
    .cim-submit-btn {
        justify-content: center;
        padding: 16px;
    }
    
    .cim-lightbox-close {
        right: 20px;
        top: 20px;
        width: 50px;
        height: 50px;
        font-size: 35px;
    }
    
    .cim-lightbox-caption {
        bottom: 20px;
        font-size: 15px;
        padding: 12px 25px;
    }
}

@media (max-width: 480px) {
    .cim-gallery {
        grid-template-columns: 1fr;
    }
    
    .cim-public-title {
        font-size: 24px;
    }
}

/* Bouton secondaire */
.cim-btn-secondary {
    background: linear-gradient(135deg, #F39207 0%, #d67f06 100%);
    color: white;
    border: 2px solid #F39207;
}

.cim-btn-secondary:hover {
    background: linear-gradient(135deg, #d67f06 0%, #F39207 100%);
    border-color: #d67f06;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(243, 146, 7, 0.4);
}

/* Actions header - ajuster pour 2 boutons */
.cim-result-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Responsive pour les boutons */
@media (max-width: 768px) {
    .cim-result-actions {
        width: 100%;
    }
    
    .cim-result-actions .cim-btn {
        flex: 1;
        min-width: 150px;
    }
}