/**
 * bip-style.css
 * Batch Image Processing and Gallery (BIP) - shared stylesheet
 *
 * Used by all four pages: bipa.php, bipga.php, index.php, process_log.php.
 * Consolidated from what were four separate <style> blocks. Where the
 * same class existed on more than one page with the same definition,
 * it appears once here. Where a page's controls are unique to it, the
 * section is labelled with which page(s) use it. Where two pages used
 * the same class name for genuinely different visual purposes, a
 * small page-scoped override class keeps each page looking exactly as
 * it did before this consolidation - see the "PAGE-SPECIFIC OVERRIDES"
 * section near the bottom.
 */

/* ==========================================
   THEME VARIABLES (all pages)
   ========================================== */
:root {
    --bg: #0f172a;
    --card: #1e293b;
    --card-section: #0f172a;
    --accent: #3b82f6;
    --text: #f8fafc;
    --muted: #94a3b8;
    --success: #22c55e;
    --error: #ef4444;
    --border: #334155;
    --badge-blue: #1e3a8a;
    --badge-blue-text: #93c5fd;
    --badge-amber: #451a03;
    --badge-amber-text: #fde68a;
    --badge-green: #064e3b;
    --badge-green-text: #6ee7b7;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-border: #f59e0b;
}

/* ==========================================
   BASE PAGE LAYOUT (all pages)
   ========================================== */
body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}
.container {
    width: 100%;
    max-width: 900px;
    flex: 1;
}
.card {
    background-color: var(--card);
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}
h1, h2, h3, h4 { margin-top: 0; }
a { color: var(--badge-blue-text); }

/* Admin-page title bar (bipa.php, bipga.php - a <div class="header">
   wrapping the page title and the logout link). index.php's page
   header is a different, more complex control bar - see
   ".header-controls" etc. under "INDEX.PHP" below. */
.header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Admin-page footer (bipa.php, bipga.php - a <div class="footer">).
   index.php uses a semantic <footer> tag with its own look - see
   "INDEX.PHP" below. */
.footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    width: 100%;
}

/* ==========================================
   FORM CONTROLS (bipa.php, bipga.php)
   ========================================== */
label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}
input[type="text"], input[type="number"], input[type="password"], select {
    background-color: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    box-sizing: border-box;
}
input:focus, select:focus {
    outline: 2px solid var(--accent);
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.form-section {
    background-color: var(--card-section);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.section-header h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
@media (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* bipa.php only - the "process new / re-process all" radio choice */
.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

/* ==========================================
   BUTTONS (bipa.php, bipga.php)
   ========================================== */
/* Primary action button. Full-width by default (matches every bipa.php
   use); bipga.php uses it inline in a couple of spots that should stay
   their natural width - see ".btn-inline" override below. */
.btn {
    background-color: var(--accent);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* bipa.php only - directory-creation prompt button */
.btn-warning {
    background-color: #d97706;
    color: white;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-secondary {
    background-color: var(--border);
    color: var(--text);
    text-decoration: none;
    display: inline-block;
    text-align: center;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.btn-danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid var(--error);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-danger:hover { background-color: rgba(239, 68, 68, 0.3); }
.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* ==========================================
   BADGES & TAGS (bipa.php, bipga.php)
   ========================================== */
.tag-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 600;
}
.tag-photo { background: var(--badge-blue); color: var(--badge-blue-text); }
.tag-thumb { background: var(--badge-amber); color: var(--badge-amber-text); }
.tag-db { background: var(--badge-green); color: var(--badge-green-text); }

/* bipa.php only - "DB Records / Thumbs in Dir" and "Unprocessed
   Images" counter pills */
.db-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    border: 1px solid transparent;
}
.db-stat-pill.synced {
    background-color: var(--badge-green);
    color: var(--badge-green-text);
    border-color: rgba(34, 197, 94, 0.3);
}
.db-stat-pill.unsynced {
    background-color: var(--badge-amber);
    color: var(--badge-amber-text);
    border-color: rgba(245, 158, 11, 0.4);
}

/* bipa.php only - ImageMagick/GD engine indicator */
.engine-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    background: var(--border);
    color: var(--text);
}

/* ==========================================
   ALERTS (bipa.php, bipga.php)
   ========================================== */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}
.info-alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border: 1px solid var(--accent);
}
/* bipa.php only - "directories missing" prompt */
.warning-alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    background-color: var(--warning-bg);
    color: #fbbf24;
    border: 1px solid var(--warning-border);
}

/* ==========================================
   TABLES & RUN-STATUS TEXT (bipa.php batch results,
   process_log.php log entries)
   ========================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
th, td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-size: 0.85rem; }
.status-pass { color: var(--success); font-weight: 600; }
.status-fail { color: var(--error); font-weight: 600; }

/* bipa.php only */
.sys-requirements {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.75rem;
    line-height: 1.5;
}
.help-text {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}
.log-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
}

/* ==========================================
   BATCH PROGRESS OVERLAY (bipa.php only)
   ========================================== */
.progress-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.progress-overlay.active {
    display: flex;
}
.progress-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.progress-card h3 {
    margin: 0 0 1.25rem 0;
}
.progress-counter {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.progress-counter-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1.25rem;
}
.progress-bar-track {
    width: 100%;
    height: 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}
.progress-time-remaining {
    font-size: 0.9rem;
    color: var(--muted);
}
.progress-time-remaining strong {
    color: var(--text);
}

/* ==========================================
   GALLERY MANAGEMENT (bipga.php only)
   ========================================== */
.gallery-row {
    display: grid;
    grid-template-columns: 50px 1.3fr 1.8fr 1.3fr auto;
    gap: 1rem;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
@media (max-width: 768px) {
    .gallery-row { grid-template-columns: 1fr; }
}
.batch-toolbar {
    background-color: var(--card-section);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.image-row {
    display: grid;
    grid-template-columns: auto 1.7fr 1.1fr auto;
    grid-template-rows: auto auto;
    gap: 0.5rem 1rem;
    align-items: center;
    background-color: var(--card-section);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}
.row-title      { grid-column: 2; grid-row: 1; }
.row-desc       { grid-column: 2; grid-row: 2; }
.row-gallery    { grid-column: 3; grid-row: 1; }
.row-subgallery { grid-column: 3; grid-row: 2; }
.row-update     { grid-column: 4; grid-row: 1; }
.row-delete     { grid-column: 4; grid-row: 2; }
@media (max-width: 850px) {
    .image-row { grid-template-columns: 1fr; grid-template-rows: auto; }
    .thumb-container { grid-column: 1; grid-row: auto; }
    .row-title, .row-desc, .row-gallery, .row-subgallery, .row-update, .row-delete {
        grid-column: 1;
        grid-row: auto;
    }
}
.thumb-container {
    grid-column: 1;
    grid-row: 1 / span 2;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.thumb-preview-link {
    display: inline-block;
    line-height: 0;
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.thumb-preview-link:hover {
    transform: scale(1.03);
    border-color: var(--accent);
}
.full-thumb-img {
    display: block;
}

/* ==========================================
   PAGINATION (bipga.php Image Metadata list,
   index.php public gallery)
   ========================================== */
.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}
.pagination .active {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* ==========================================
   INDEX.PHP (public gallery) - own header/footer style,
   gallery grid, and lightbox. Not shared with the admin pages.
   ========================================== */
header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
}
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.filter-form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
/* index.php's own select look (card-colored, larger padding) - scoped
   to its filter bar so it doesn't affect bipga.php's <select> elements,
   which use the shared input/select rule above instead. */
.filter-form select {
    background-color: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
}

.gallery-info-header {
    text-align: center;
    margin: 1.5rem auto 2rem auto;
    max-width: 800px;
}
.gallery-info-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 0.5rem;
}
.gallery-info-desc {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.5;
}

/* Responsive grid: 2 to 4 columns */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}
@media (min-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

.gallery-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.gallery-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

.thumb-wrapper {
    width: 100%;
    aspect-ratio: 4/3;
    background-color: #020617;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.thumb-wrapper:hover .thumb-img { transform: scale(1.05); }

.meta-container {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
}
.item-title {
    font-weight: bold;
    font-size: 1rem;
    color: var(--text);
    word-break: break-word;
}
.item-description {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.4;
    word-break: break-word;
}

/* Lightbox overlay */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.lightbox-overlay.active { display: flex; }
.lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 0.25rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5);
}
.lightbox-caption {
    margin-top: 1rem;
    text-align: center;
    max-width: 80vw;
}
.lightbox-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
}
.lightbox-desc {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 0.25rem;
}
.lightbox-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 2rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background 0.2s ease;
    user-select: none;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-close { top: 1.5rem; right: 1.5rem; }
.lightbox-prev { left: 1.5rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1.5rem; top: 50%; transform: translateY(-50%); }

footer {
    margin-top: auto;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    padding-top: 2rem;
}

/* ==========================================
   PAGE-SPECIFIC OVERRIDES
   A few properties were intentionally different per page before this
   consolidation (different container widths, etc). These small,
   targeted overrides preserve each page's exact prior appearance.
   ========================================== */

/* bipga.php: wider content column than bipa.php's default 900px */
.container-bipga { max-width: 1100px; }

/* index.php: wider still, and its own vertical rhythm (no flex-grow on
   the container, slightly tighter body padding) */
.container-index { max-width: 1200px; flex: initial; }
.bip-page-index { padding: 2rem 1rem; }

/* bipga.php: a couple of .btn uses should keep their natural width
   rather than the full-width default above */
.btn-inline { width: auto; }

/* process_log.php: this page has no .card wrapper, so its table needs
   its own background (and slightly tighter cell padding, and a darker
   header row) to stand out against the page background - matching its
   exact original look before consolidation. */
.log-page table { background: var(--card); margin-bottom: 2rem; }
.log-page th, .log-page td { padding: 0.6rem; }
.log-page th { background: var(--bg); }
