/* Library Layout */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.library-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
}

.search-box input {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 300px;
    font-size: 1rem;
}

/* Upload Section */
.upload-section {
    background: white;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-section.dragover {
    background: #e3f2fd;
    border-color: #2196f3;
}

.upload-drop-zone {
    cursor: pointer;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #666;
}

/* Grid Layout */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.library-item {
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

.library-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.item-preview {
    height: 160px;
    width: 100%;
    background: #f8f9fa; /* Checkerboard pattern ideally */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.item-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.item-info {
    padding: 0.75rem;
    border-top: 1px solid #eee;
}

.item-name {
    font-size: 0.85rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 900px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    z-index: 10;
}

.details-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    height: 600px;
}

.details-preview {
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.details-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.details-info {
    padding: 2rem;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.info-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.info-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    background: #f8f9fa;
}

.url-copy-group {
    display: flex;
    gap: 5px;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: auto;
}

.btn-danger:hover {
    background-color: #c82333;
}

.replace-image-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px; /* Space between replace and delete buttons */
}

.replace-image-section label.btn.btn-secondary {
    cursor: pointer;
    margin-top: 0; /* Override default button margin if any */
    flex-shrink: 0; /* Prevent button from shrinking */
}

.filename-display {
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1; /* Allow filename to take up available space */
}