/* Amigurumi Gallery - Style.css */

:root {
    --primary: #d4a574;
    --primary-dark: #c49564;
    --secondary: #8b7355;
    --accent: #e8c59e;
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --text: #3d352e;
    --text-light: #6b5e53;
    --border: #e8dfd6;
    --shadow: rgba(61, 53, 46, 0.08);
    --shadow-hover: rgba(61, 53, 46, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
    --font: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.logo a:hover {
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-light);
    transition: all var(--transition);
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    background: var(--accent);
    color: var(--text);
}

/* Main */
.main {
    flex: 1;
    padding: 40px 0;
}

/* Hero */
.hero {
    text-align: center;
    padding: 40px 20px;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -1px;
}

.logo {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.hero-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.hero-logo {
    width: 250px;
    height: auto;
    flex-shrink: 0;
    margin-left: -100px;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto;
}

/* Filters */
.filters {
    margin-bottom: 32px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px var(--shadow);
}

.filter-group {
    flex: 1;
    min-width: 180px;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.3);
}

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

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.gallery-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-hover);
}

.card-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.gallery-card:hover .card-image img {
    transform: scale(1.05);
}

.placeholder-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--border);
}

.difficulty-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-beginner {
    background: #d4edda;
    color: #155724;
}

.difficulty-intermediate {
    background: #fff3cd;
    color: #856404;
}

.difficulty-advanced {
    background: #f8d7da;
    color: #721c24;
}

.card-content {
    padding: 20px;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-title a {
    color: var(--text);
}

.card-title a:hover {
    color: var(--primary);
}

.card-category {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    background: var(--accent);
    color: var(--text);
    border-radius: 20px;
    margin-bottom: 10px;
    text-transform: capitalize;
}

.card-description {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-light);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Public Gallery (no login) */
.nav-admin-btn {
    padding: 10px 20px;
}

.public-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.public-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.public-card {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.public-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-hover);
}

.public-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.public-card:hover img {
    transform: scale(1.05);
}

.public-card figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 28px 14px 12px;
    background: linear-gradient(to top, rgba(61, 53, 46, 0.78), transparent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state a {
    font-weight: 600;
}

/* Detail Page */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 24px;
    font-weight: 500;
    color: var(--text-light);
}

.back-link:hover {
    color: var(--primary);
}

.detail {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
}

.detail-header {
    padding: 32px;
    border-bottom: 1px solid var(--border);
}

.detail-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-category {
    background: var(--accent);
    color: var(--text);
}

.badge-difficulty {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-difficulty.difficulty-beginner {
    background: #d4edda;
    color: #155724;
}

.badge-difficulty.difficulty-intermediate {
    background: #fff3cd;
    color: #856404;
}

.badge-difficulty.difficulty-advanced {
    background: #f8d7da;
    color: #721c24;
}

/* Gallery */
.detail-gallery {
    padding: 32px;
}

.main-image {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
    margin-bottom: 16px;
    aspect-ratio: 1;
}

.main-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.main-image .placeholder-image {
    aspect-ratio: 1;
}

.thumbnails {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 8px 4px;
}

.thumbnail {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0.6;
    border: 2px solid transparent;
    transition: all var(--transition);
    flex-shrink: 0;
}

.thumbnail:hover,
.thumbnail.active {
    opacity: 1;
    border-color: var(--primary);
}

/* Detail Content */
.detail-content {
    padding: 0 32px 32px;
}

.detail-section {
    margin-bottom: 32px;
}

.detail-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.description {
    color: var(--text-light);
    white-space: pre-wrap;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.detail-list dt {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-list dd {
    font-size: 1rem;
    color: var(--text);
}

/* Admin Styles */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 1.75rem;
}

.admin-actions {
    display: flex;
    gap: 12px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
}

.admin-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    transition: box-shadow var(--transition);
}

.admin-card:hover {
    box-shadow: 0 8px 24px var(--shadow-hover);
}

.admin-card[draggable="true"] {
    cursor: grab;
}

.admin-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.admin-card-image {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg);
}

.admin-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.admin-card-content {
    padding: 20px;
}

.admin-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.admin-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.admin-card-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-danger {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.btn-danger:hover {
    background: #f5c6cb;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Photo Upload */
.photo-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    margin-bottom: 24px;
    transition: border-color var(--transition), background var(--transition);
}

.photo-upload:hover,
.photo-upload.dragover {
    border-color: var(--primary);
    background: rgba(212, 165, 116, 0.05);
}

.photo-upload input[type="file"] {
    display: none;
}

.photo-upload-label {
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-light);
}

.photo-upload-label:hover {
    color: var(--primary);
}

.upload-icon {
    font-size: 2.5rem;
}

.photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
}

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

.photo-item-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

.photo-item:hover .photo-item-actions {
    opacity: 1;
}

.photo-item-actions button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: background var(--transition);
}

.photo-item-actions button:hover {
    background: var(--bg);
}

.photo-item-actions .btn-primary-photo {
    background: #fff;
    color: #b0b0b0;
    border: 1px solid #e0e0e0;
}

.photo-item-actions .btn-primary-photo:hover {
    background: #fff8e1;
    color: #c8a200;
}

.photo-item-actions .btn-primary-photo.active {
    background: #f5b301;
    color: #fff;
    border-color: #f5b301;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f5b301;
}

.photo-item-actions .btn-delete {
    color: #721c24;
}

/* Login */
.login-container {
    max-width: 400px;
    margin: 60px auto;
    padding: 40px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px var(--shadow);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 1.5rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form button {
    width: 100%;
}

/* Messages */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: auto;
}

.footer p {
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-title {
        flex-direction: column;
        gap: 10px;
    }

    .hero-logo {
        width: 200px;
        margin-left: 0;
    }
    
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: 0;
    }
    
    .btn {
        width: 100%;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .public-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .detail-header h1 {
        font-size: 1.5rem;
    }
    
    .detail-gallery {
        padding: 20px;
    }
    
    .detail-content {
        padding: 0 20px 20px;
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
    }
    
    .login-container {
        margin: 20px;
        padding: 24px;
    }

    /* Prevent horizontal overflow from navigation links */
    .header .container {
        flex-wrap: wrap;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
        margin-top: 8px;
    }

    .nav-link {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gallery-card {
    animation: fadeIn 0.4s ease forwards;
}

.gallery-card:nth-child(1) { animation-delay: 0.05s; }
.gallery-card:nth-child(2) { animation-delay: 0.1s; }
.gallery-card:nth-child(3) { animation-delay: 0.15s; }

/* Junior Viewer Protection */
.junior-viewer .card-image img,
.junior-viewer .main-image img,
.junior-viewer .thumbnail,
.junior-viewer .admin-card-image img,
.junior-viewer .photo-item img,
.junior-viewer .detail-gallery,
.junior-viewer .patterns-list {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: auto;
}

.junior-viewer .card-image,
.junior-viewer .main-image {
    position: relative;
}

.junior-viewer .card-image::after,
.junior-viewer .main-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: none;
    z-index: 1;
}

.junior-viewer .card-image img,
.junior-viewer .main-image img {
    pointer-events: none;
}

.junior-viewer .download-pattern-link,
.junior-viewer .download-photo-link {
    display: none !important;
}
.gallery-card:nth-child(4) { animation-delay: 0.2s; }
.gallery-card:nth-child(5) { animation-delay: 0.25s; }
.gallery-card:nth-child(6) { animation-delay: 0.3s; }