@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700&family=Gorditas:wght@400;700&family=Permanent+Marker&display=swap');

:root {
    --primary: #003366; /* Deep Barn Blue */
    --secondary: #d32f2f; /* Barn Red */
    --accent: #4e342e; /* Natural Wood Brown */
    --cream: #f9f7e8;
    --slate: #3b4249;
    --border-width: 4px;
    --radius: 16px;
    --font-main: 'Outfit', sans-serif;
    --font-fun: 'Gorditas', cursive;
    --font-hand: 'Permanent Marker', cursive;
}

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

h1, h2, h3 {
    font-family: var(--font-main);
}

body {
    font-family: var(--font-main);
    background: url('../bg-wood.png') repeat;
    background-size: 800px;
    color: var(--slate);
    min-height: 100vh;
    padding: 10px 20px 20px;
    line-height: 1.6;
}

/* Match homepage: body has .container padding (10px), nav header adds the rest */
body > header.cafe-top-nav {
    padding-top: 20px;
    padding-bottom: 20px;
    margin-bottom: 5px;
}

.device-desktop body > header.cafe-top-nav {
    padding-top: 15px;
    padding-bottom: 15px;
}

.admin-page {
    --border-width: 2px;
    --radius: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 0.9rem;
}

.admin-page header:not(.cafe-top-nav) {
    margin-bottom: 20px;
}

.admin-page .chunky-box {
    padding: 12px;
}

.admin-page input, .admin-page textarea, .admin-page select {
    padding: 8px;
    font-size: 0.9rem;
}

.admin-page .form-group {
    margin-bottom: 10px;
}

/* Chunky Box Pattern */
.chunky-box {
    background: white;
    border: var(--border-width) solid var(--primary);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 6px 6px 0 rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.chunky-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 10px;
    background: var(--cream);
    opacity: 0.5;
    pointer-events: none;
}

/* Cafe site nav spacing lives in ../css/main.css (.cafe-top-nav) */

.admin-toolbar,
.book-bistro-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.admin-toolbar .header-title,
.book-bistro-toolbar .header-title {
    margin-top: 0;
}

/* Header & Logo (legacy book-bistro headers only) */
header:not(.cafe-top-nav):not(.admin-toolbar) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    gap: 20px;
    flex-wrap: wrap;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-container img {
    height: 150px;
    width: 150px;
    object-fit: contain;
}

.header-title {
    font-family: var(--font-fun);
    font-weight: 700;
    font-size: 2.8rem;
    color: var(--primary);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.05);
    margin-top: 15px; /* Move down from the wood line */
}

.admin-page .header-title {
    font-size: 2.2rem;
    margin-top: 0;
}

.admin-page .logo-container img {
    height: 70px;
    width: 70px;
}

/* Navigation */
nav {
    display: flex;
    gap: 10px;
}

.btn {
    text-decoration: none;
    padding: 12px 24px;
    border: var(--border-width) solid var(--primary);
    border-radius: var(--radius);
    background: royalblue;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: var(--primary);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: royalblue;
}

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

/* Specific for Admin Dashboard to give more space to list */
.admin-page .grid {
    grid-template-columns: minmax(420px, 38%) 1fr;
    gap: 20px;
    flex: 1;
    overflow: hidden;
    padding-bottom: 10px;
    min-height: 0;
}

.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    min-height: 0;
    max-height: 100%;
    min-width: 420px;
    align-self: stretch;
}

.admin-sidebar .chunky-box {
    flex-shrink: 0;
    padding: 16px 18px 18px;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

.admin-sidebar input,
.admin-sidebar textarea,
.admin-sidebar select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.data-utilities-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: 100%;
}

.admin-sidebar .btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 10px 12px;
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    .admin-page .grid {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        min-width: 0;
    }
}


/* Book Card */
.book-card {
    background: white;
    background-image: linear-gradient(rgba(255,255,255,0.9), rgba(255,255,255,0.9)), url('../bg-wood.png');
    background-size: cover;
    border: var(--border-width) solid var(--primary);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 220px;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.05);
}

.book-card:hover {
    transform: translateY(-5px) rotate(1deg);
    box-shadow: 8px 8px 0 rgba(0,0,0,0.1);
}

.book-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 5px;
}

.book-author {
    font-style: italic;
    color: var(--slate);
    margin-bottom: 10px;
}

.basket-section, .keywords-section {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
}

.keyword-tag {
    background: var(--cream);
    border: 2px solid var(--primary);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--primary);
    white-space: nowrap;
    transition: transform 0.1s, background 0.1s;
}

.clickable-tag {
    cursor: pointer;
}

.clickable-tag:hover {
    transform: scale(1.1);
    filter: brightness(0.95);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

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

label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--primary);
}

input, textarea {
    width: 100%;
    padding: 12px;
    border: var(--border-width) solid var(--primary);
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-size: 1rem;
}

/* Search Bar */
.search-container {
    margin-bottom: 30px;
    max-width: 600px;
}

/* Scalloped Divider */
.scallop {
    height: 20px;
    background: var(--primary);
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 3"><path d="M0,0 Q2.5,3 5,0 T10,0" fill="white"/></svg>');
    mask-size: 40px 20px;
}

/* Admin Inventory List Selection */
#admin-books-list .chunky-box {
    padding: 12px 20px;
    background: #f9f9f9;
    flex-shrink: 0;
    border-width: 2px;
    transition: transform 0.1s, background 0.1s;
    min-height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#admin-books-list .chunky-box:hover {
    background: var(--cream);
    transform: translateX(10px);
}

#admin-books-list .chunky-box:active {
    background: white;
    transform: translateX(5px);
}

#admin-books-list .chunky-box.selected {
    border-color: var(--secondary);
    background: var(--cream);
    transform: translateX(5px);
    box-shadow: 0 0 15px rgba(211, 47, 47, 0.3);
}

#admin-books-list .chunky-box.selected::after {
    content: 'SELECTED';
    position: absolute;
    top: 5px; right: 10px;
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--secondary);
}

@media (max-width: 600px) {
    header {
        flex-direction: column;
        text-align: center;
    }
    .grid {
        grid-template-columns: 1fr;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-box {
    width: 100%;
    max-width: 400px;
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
