@import url("../shared/variables.css");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Override accent for admin interface */
:root {
    --accent: var(--accent-admin);
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #3a8eef;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-number {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filters input,
.filters select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filters input {
    flex: 1;
}

.filters select {
    min-width: 150px;
}

.works-table {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

thead {
    background: var(--bg-hover);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

td {
    padding: 0.4rem 1rem;
    border-top: 1px solid var(--border);
}

tbody tr:hover {
    background: var(--bg-hover);
}

.preview {
    width: 60px;
    height: 40px;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.btn-small {
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 0.5rem;
    transition: all 0.2s;
    border: none;
}

.btn-edit {
    background: var(--accent);
    color: white;
}

.btn-edit:hover {
    background: #3a8eef;
}

.btn-duplicate {
    background: #6c757d;
    color: white;
}

.btn-duplicate:hover {
    background: #5a6268;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    padding: 1rem;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 6px;
    width: 100%;
    max-width: 550px;
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 0.5rem 0.75rem 0.75rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.form-group {
    margin-bottom: 0.35rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

textarea {
    width: 100% !important;
    resize: vertical;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.8rem;
}

.form-group textarea {
    min-height: 50px;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.form-actions .btn {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

.build-status {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 2000;
}

.build-status.show {
    opacity: 1;
    transform: translateY(0);
}

.build-status.success {
    background: var(--success);
    color: white;
}

.build-status.error {
    background: var(--error);
    color: white;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .filters {
        flex-direction: column;
    }

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

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.5rem;
    }
}

/* Content Grid - unified system for images, text, and videos */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    margin-top: 0.25rem;
    min-height: 60px;
}

.content-item {
    position: relative;
    aspect-ratio: 16/10;
    border: 2px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    cursor: move;
    background: var(--bg-dark);
}

.content-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.content-item.content-text {
    background: var(--bg-secondary);
    padding: 0.5rem;
    display: flex;
    align-items: flex-start;
}

.content-item.content-text .text-preview {
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.content-item.content-video {
    border-color: #ff0000;
}

.content-item .video-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: #ff0000;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
}

.content-item .remove-content {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.content-item .caption-btn,
.content-item .edit-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.content-item .caption-btn.has-caption {
    background: var(--success);
    color: white;
    border-color: var(--success);
    opacity: 1;
}

.content-item:hover .remove-content,
.content-item:hover .caption-btn,
.content-item:hover .edit-btn {
    opacity: 1;
}

.content-item .content-order {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.content-item.dragging {
    opacity: 0.5;
}

.content-add-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.form-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Legacy: keep images-grid for backwards compat */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.35rem;
    margin-top: 0.25rem;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    cursor: move;
    background: var(--bg-dark);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-preview-item .caption-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-preview-item .caption-btn.has-caption {
    background: var(--success);
    color: white;
    border-color: var(--success);
    opacity: 1;
}

.image-preview-item:hover .remove-image,
.image-preview-item:hover .caption-btn {
    opacity: 1;
}

/* Caption edit modal */
.caption-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.caption-modal.active {
    display: flex;
}

.caption-modal-content {
    background: var(--bg-secondary);
    border-radius: 6px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
    padding: 1rem;
}

.caption-modal-content h3 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.caption-modal-content textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.85rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.caption-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.caption-modal-actions .btn {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

.image-preview-item .image-order {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.image-preview-item.dragging {
    opacity: 0.5;
}

.add-image-btn {
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: 4px;
    background: var(--bg-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.add-image-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.add-image-btn input {
    display: none;
}

.featured-checkbox {
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.featured-checkbox:hover {
    opacity: 0.6;
}

.featured-checkbox.active {
    opacity: 1;
}
