/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --pew-olive: #4b5320;
    --pew-olive-dark: #3a4119;
    --pew-tan: #d2b48c;
    --pew-tan-light: #f7f3e8;
    --pew-red: #c0392b;
    --pew-text: #2c3e50;
    --pew-border: #e0e0e0;
}

#pew-locker-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--pew-text);
    box-sizing: border-box;
}

#pew-locker-wrapper * {
    box-sizing: border-box;
}


.pew-swipe-hint { display: none; }

/* =========================================
   2. HEADERS & TYPOGRAPHY
   ========================================= */
.pew-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--pew-tan);
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.pew-header h2, .pew-header h1 {
    color: var(--pew-olive);
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0;
}

.pew-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* =========================================
   3. BUTTONS (NUCLEAR OPTION)
   ========================================= */
#pew-locker-wrapper button,
#pew-locker-wrapper .pew-btn-primary,
#pew-locker-wrapper .pew-btn-text,
#pew-locker-wrapper .btn-archive,
#pew-locker-wrapper .btn-edit,
#pew-locker-wrapper #btn-print-qr {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.2;
    box-shadow: none !important;
}

/* Primary Action */
#pew-locker-wrapper .pew-btn-primary,
#pew-locker-wrapper .pew-btn-save {
    background-color: var(--pew-olive) !important;
    color: #fff !important;
    border: 1px solid var(--pew-olive) !important;
    margin: 10px;
}

#pew-locker-wrapper .pew-btn-primary:hover,
#pew-locker-wrapper .pew-btn-save:hover {
    background-color: var(--pew-olive-dark) !important;
    border-color: var(--pew-olive-dark) !important;
    transform: translateY(-1px);
}

/* Secondary / Outline Buttons */
#pew-locker-wrapper .btn-edit,
#pew-locker-wrapper #btn-print-qr,
#pew-locker-wrapper #btn-open-estate {
    background-color: #fff !important;
    color: var(--pew-olive) !important;
    border: 1px solid var(--pew-olive) !important;
}

#pew-locker-wrapper .btn-edit:hover,
#pew-locker-wrapper #btn-print-qr:hover,
#pew-locker-wrapper #btn-open-estate:hover {
    background-color: var(--pew-tan-light) !important;
}

/* Danger Buttons */
#pew-locker-wrapper .btn-archive,
#pew-locker-wrapper #btn-burn-notice {
    color: var(--pew-red) !important;
    border: 1px solid var(--pew-red) !important;
    background: #fff !important;
}

#pew-locker-wrapper #btn-burn-notice {
    background-color: var(--pew-red) !important;
    color: #fff !important;
}

#pew-locker-wrapper .btn-archive:hover {
    background-color: #fff5f5 !important;
}

/* Disabled */
#pew-locker-wrapper .pew-btn-disabled {
    background-color: #ccc !important;
    color: #fff !important;
    cursor: not-allowed;
    border: none !important;
}

/* Links */
#pew-locker-wrapper .pew-back-link {
    color: var(--pew-olive);
    text-decoration: none;
    font-weight: 600;
}

/* =========================================
   4. TABS (DESKTOP DEFAULT)
   ========================================= */
.pew-tabs { display: flex; gap: 5px; }

.pew-tabs a {
    padding: 8px 16px;
    text-decoration: none;
    color: #666;
    background: #f4f4f4;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
}

.pew-tabs a.active { background-color: var(--pew-olive); color: #fff; }
.pew-tabs a:hover:not(.active) { background-color: var(--pew-tan); color: #fff; }

/* Detail View Tabs (Scrollable Container) */
.pew-detail-tabs {
    display: flex;
    border-bottom: 2px solid var(--pew-olive);
    margin-bottom: 25px;
    gap: 5px;
    overflow-x: auto;
    white-space: nowrap;


    /* Chrome/Safari Scrollbar Styling */
    scrollbar-width: thin;
    scrollbar-color: var(--pew-olive) #f1f1f1;
}

.pew-detail-tabs::-webkit-scrollbar { height: 4px; }
.pew-detail-tabs::-webkit-scrollbar-thumb { background: var(--pew-olive); border-radius: 2px; }
.pew-detail-tabs::-webkit-scrollbar-track { background: #f1f1f1; }

.pew-tab-btn {
    background: #f4f4f4 !important;
    border: none !important;
    padding: 10px 20px !important;
    cursor: pointer;
    font-size: 14px;
    color: #666 !important;
    font-weight: 600;
    border-radius: 6px 6px 0 0 !important;
    transition: all 0.2s;
    flex-shrink: 0; /* Prevents squishing */
}

.pew-tab-btn:hover { background: #e0e0e0 !important; color: #333 !important; }
.pew-tab-btn.active { background-color: var(--pew-olive) !important; color: #fff !important; }

.pew-tab-content { display: none; animation: fadeIn 0.3s ease-out; }
.pew-tab-content.active { display: block; }

/* =========================================
   5. GRID & CARDS
   ========================================= */
#pew-inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 25px;
}

.pew-card {
    background: white;
    border: 1px solid var(--pew-border);
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.pew-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(75, 83, 32, 0.15);
    border-color: var(--pew-tan);
}

.pew-card-img {
    height: 180px;
    width: 100%;
    background-size: cover;
    background-position: center;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--pew-border);
}

.pew-card-body { padding: 15px; flex-grow: 1; }
.pew-card-body h3 { margin: 0 0 5px 0; font-size: 1.1rem; color: var(--pew-text); }

.pew-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
    background: var(--pew-tan-light);
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
}

.pew-card-actions {
    padding: 10px 15px;
    background: #fcfcfc;
    border-top: 1px solid var(--pew-border);
    display: flex;
    justify-content: space-between;
}

/* =========================================
   6. FORMS & INPUTS
   ========================================= */
input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="email"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    transition: border 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--pew-olive);
    box-shadow: 0 0 0 2px rgba(75, 83, 32, 0.1);
}

#pew-add-form {
    background: #fff;
    padding: 25px;
    border: 2px solid var(--pew-olive);
    border-radius: 8px;
    margin-bottom: 30px;
}

.pew-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 15px; }
.pew-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 15px; }

/* =========================================
   7. DROPZONES & UPLOADS
   ========================================= */
.pew-dropzone {
    border: 2px dashed var(--pew-tan);
    background: var(--pew-tan-light);
    border-radius: 6px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.pew-dropzone:hover { border-color: var(--pew-olive); background: #fff; }
.pew-dropzone i { font-size: 28px; color: var(--pew-olive); margin-bottom: 10px; display: block; font-style: normal; }
.pew-dropzone p { margin: 0; font-weight: 600; color: var(--pew-olive); }

/* =========================================
   8. DATA DISPLAY & LOGS
   ========================================= */
.pew-data-point label { font-size: 0.75rem; text-transform: uppercase; color: #888; letter-spacing: 0.5px; margin-bottom: 4px; }
.pew-data-point div { font-weight: 600; font-size: 1.05rem; color: var(--pew-text); }

/* Accessories */
.pew-accessory-row {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; border: 1px solid var(--pew-border);
    padding: 12px; margin-bottom: 8px; border-radius: 4px; transition: border 0.2s;
}
.pew-accessory-row:hover { border-color: var(--pew-tan); }
.pew-accessory-row h4 { margin: 0; font-size: 0.95rem; color: var(--pew-text); }
.pew-acc-link { color: var(--pew-olive); font-size: 0.85rem; font-weight: 600; margin-left: 8px; }

/* Logs */
.pew-log-item { display: flex; padding: 15px; border-bottom: 1px solid var(--pew-border); background: #fff; }
.log-date { font-weight: 700; color: var(--pew-olive); font-size: 0.9rem; width: 110px; }
.log-details strong { color: var(--pew-text); }

/* --- LOG TABLE STYLING --- */
.pew-table-wrapper {
    overflow-x: auto;
}

.pew-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.pew-data-table th {
    text-align: left;
    background: #f4f4f4;
    padding: 10px;
    border-bottom: 2px solid #ddd;
    color: #666;
    font-weight: 600;
}

.pew-data-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.pew-data-table tr:last-child td {
    border-bottom: none;
}

/* THE MISSING THUMBNAIL STYLE */
.pew-table-thumb {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    background-color: #eee;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    border: 1px solid #ccc;
    transition: transform 0.2s;
}

.pew-table-thumb:hover {
    transform: scale(1.5);
    z-index: 10;
    position: relative;
    border-color: #4b5320;
}

/* =========================================
   9. MODALS & UTILS
   ========================================= */
#pew-toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; }
.pew-toast {
    padding: 12px 20px; color: white; background: #333;
    border-radius: 4px; margin-top: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); font-weight: 500;
}
.pew-toast.success { background: var(--pew-olive); }
.pew-toast.error { background: var(--pew-red); }

#pew-crop-modal, #pew-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 100000;
    display: none; align-items: center; justify-content: center;
}
.pew-crop-content { background: white; padding: 20px; border-radius: 8px; max-width: 600px; width: 90%; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   10. VIEW TOGGLE BUTTONS
   ========================================= */
.pew-view-toggle { display: flex; gap: 5px; margin-left: auto; }

#pew-locker-wrapper .pew-view-btn {
    background: #fff !important;
    border: 1px solid #ccc !important;
    color: #aaa !important;
    padding: 6px 10px !important;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
}

#pew-locker-wrapper .pew-view-btn:hover {
    border-color: var(--pew-olive) !important;
    color: var(--pew-olive) !important;
}

#pew-locker-wrapper .pew-view-btn.active {
    background-color: var(--pew-olive) !important;
    border-color: var(--pew-olive) !important;
    color: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15) !important;
}

/* =========================================
   11. LIST VIEW OVERRIDES
   ========================================= */
#pew-inventory-grid.list-view { display: flex; flex-direction: column; gap: 10px; }
#pew-inventory-grid.list-view .pew-card { flex-direction: row; height: auto; min-height: 90px; align-items: stretch; }
#pew-inventory-grid.list-view .pew-card-img { width: 100px; height: auto; border-bottom: none; border-right: 1px solid var(--pew-border); }
#pew-inventory-grid.list-view .pew-card-body { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; }
#pew-inventory-grid.list-view .pew-card-body h3 { margin: 0; font-size: 1rem; flex-grow: 1; }
#pew-inventory-grid.list-view .pew-meta { margin-left: 15px; }
#pew-inventory-grid.list-view .pew-card-actions { border-top: none; border-left: 1px solid var(--pew-border); flex-direction: row; align-items: center; gap: 8px; background: #fafafa; padding: 0 15px; min-width: auto; }

/* Live Search Styling */
#pew-live-search {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    height: 38px; /* Match button height */
}

/* --- TUTORIAL MODAL --- */
#pew-tutorial-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.45); z-index: 999999;
    display: flex; align-items: center; justify-content: center;
}

.pew-tut-content {
    background: #fff; width: 90%; max-width: 500px;
    border-radius: 8px; position: relative; overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
}

#pew-tut-close {
    position: absolute; top: 10px; right: 15px;
    background: none; border: none; font-size: 28px;
    color: #999; cursor: pointer; z-index: 10;
}

.pew-slide {
    display: none; padding: 40px 30px 20px 30px; text-align: center;
    animation: fadeIn 0.3s;
}
.pew-slide.active { display: block; }

.pew-slide img {
    max-width: 100%; height: auto; max-height: 200px;
    margin-bottom: 20px; border-radius: 4px;
}

.pew-slide h3 { margin: 0 0 15px 0; color: #4b5320; font-size: 22px; }
.pew-slide p { font-size: 15px; line-height: 1.5; color: #555; }

.pew-tut-footer {
    padding: 20px 30px; border-top: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
}

#pew-tut-dots { display: flex; gap: 8px; }
.pew-dot { width: 10px; height: 10px; border-radius: 50%; background: #ddd; transition: 0.3s; }
.pew-dot.active { background: #4b5320; transform: scale(1.2); }

/* The '?' Trigger Button */
.pew-btn-help {
    width: 32px; height: 32px; border-radius: 50%;
    background: #fff; border: 1px solid #ccc;
    color: #4b5320; font-weight: bold; font-size: 16px;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    margin-right: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.pew-btn-help:hover { background: #f4f4f4; border-color: #4b5320; }

/* --- FIX OVERSIZED IMAGE PREVIEW IN ADD/EDIT FORM --- */

/* 1. Constrain the container height when a preview is active */
#pew-add-form #crop-preview-container {
    max-height: 250px; /* Maximum height for the preview area */
    width: 100%;
    display: flex; /* Enables centering */
    align-items: center; /* Vertical center */
    justify-content: center; /* Horizontal center */
    overflow: hidden; /* Crop anything that somehow escapes */
    background-color: #f9f9f9; /* Match dropzone background */
    border-radius: 8px;
}

/* 2. Constrain the image itself */
#pew-add-form #crop-preview {
    max-height: 100%; /* Do not exceed the container height defined above */
    max-width: 100%; /* Do not exceed container width */
    width: auto; /* Maintain aspect ratio */
    height: auto; /* Maintain aspect ratio */
    object-fit: contain; /* Ensure the entire image is visible (no awkward cropping) */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Optional: adds a little depth */
}

/* Optional: Hide the filename text below the image to save more space */
#pew-add-form #main-filename {
    display: none !important;
}

/* --- THUMBNAIL PREVIEW STYLE --- */
#pew-add-form #crop-preview-container {
    background: transparent !important;
    border: none !important;
    display: inline-block !important; /* Shrink to fit image */
    margin-top: 10px;
    max-width: 100%;
}

#pew-add-form #crop-preview {
    height: 100px !important; /* Fixed Thumbnail Height */
    width: auto !important;
    max-width: 100%;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: zoom-in !important; /* Indicates it will enlarge */
    transition: transform 0.2s;
}

#pew-add-form #crop-preview:hover {
    transform: scale(1.05);
}

/* --- FIX LIGHTBOX HEADER ALIGNMENT --- */
#pew-lightbox-header {
    display: flex !important;
    justify-content: space-between !important; /* Pushes Title to Left, Buttons to Right */
    align-items: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 20px !important;
    background: rgba(0, 0, 0, 0.8) !important; /* Dark background for contrast */
    color: white !important;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
}

/* Style the Button Container specifically */
#pew-lightbox-header > div {
    display: flex;
    gap: 15px; /* Space between buttons */
    align-items: center;
}

/* Make the buttons look cleaner */
#pew-lightbox-header button,
#pew-lightbox-header a {
    color: white !important;
    font-size: 24px !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    text-decoration: none !important;
    line-height: 1 !important;
    opacity: 0.8;
    transition: opacity 0.2s;
}

#pew-lightbox-header button:hover,
#pew-lightbox-header a:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Ensure the title doesn't overlap on mobile */
#lb-title {
    font-weight: bold;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* --- NIGHT OPS (Dark Mode) --- */

/* Main Background */
body.pew-dark-mode {
    background-color: #121212 !important; /* Deep Black/Gray */
    color: #e0e0e0 !important;
}

/* Cards & Containers */
body.pew-dark-mode .pew-card,
body.pew-dark-mode .pew-widow-footer,
body.pew-dark-mode #pew-inventory-grid,
body.pew-dark-mode #pew-add-form form,
body.pew-dark-mode .pew-doc-card {
    background-color: #1e1e1e !important; /* Slightly lighter gray */
    border-color: #333 !important;
    color: #dcdcdc !important;
}

/* Text Overrides */
body.pew-dark-mode h1,
body.pew-dark-mode h2,
body.pew-dark-mode h3,
body.pew-dark-mode h4,
body.pew-dark-mode strong {
    color: #fff !important;
}

body.pew-dark-mode label,
body.pew-dark-mode .pew-meta,
body.pew-dark-mode .pew-data-point label {
    color: #aaa !important;
}

/* Inputs & Form Fields */
body.pew-dark-mode input,
body.pew-dark-mode select,
body.pew-dark-mode textarea {
    background-color: #2d2d2d !important;
    border: 1px solid #444 !important;
    color: #fff !important;
}

body.pew-dark-mode input::placeholder,
body.pew-dark-mode textarea::placeholder {
    color: #777 !important;
}

/* Buttons */
body.pew-dark-mode .pew-btn-text {
    color: #ccc !important;
    border-color: #555 !important;
}
body.pew-dark-mode .pew-btn-text:hover {
    background-color: #333 !important;
    color: #fff !important;
}

/* Links */
body.pew-dark-mode a {
    color: #76b041 !important; /* Lighter Tactical Green for contrast */
}

/* Table Rows */
body.pew-dark-mode .pew-data-table th {
    background-color: #252525 !important;
    color: #bbb !important;
    border-color: #444 !important;
}
body.pew-dark-mode .pew-data-table td {
    border-color: #333 !important;
}

/* Toggle Button Itself in Dark Mode */
body.pew-dark-mode #pew-theme-toggle {
    border-color: #777 !important;
    color: #fff !important;
}

/* --- DARK MODE DETAILS VIEW FIXES --- */

/* 1. The Summary Box (Under the Main Photo) */
body.pew-dark-mode #tab-overview .pew-card > div > div:first-child > div:last-child {
    background-color: #2d2d2d !important; /* Dark Gray bg */
    border-color: #444 !important;
    color: #e0e0e0 !important;
}

/* Fix the "Rounds" number specifically */
body.pew-dark-mode #tab-overview .pew-card strong {
    color: #fff !important; /* Bright White */
}
body.pew-dark-mode #tab-overview .pew-card span {
    color: #aaa !important; /* Light Gray for labels like "Rounds:" */
}

/* 2. Grid Fields (Type, Caliber, etc) */
body.pew-dark-mode .pew-data-point div {
    color: #e0e0e0 !important; /* Make values visible */
}

/* 3. Serial Number Box */
/* Targets the monospace inline style */
body.pew-dark-mode .pew-data-point div[style*="monospace"] {
    background-color: #111 !important;
    color: #76b041 !important; /* Matrix/Tactical Green */
    border: 1px solid #444;
}

/* 4. Widow's Instruction Box (The Yellow Warning Box) */
/* Overrides the bright yellow background */
body.pew-dark-mode .pew-data-point[style*="background:#fcf8e3"] {
    background-color: #3a2c05 !important; /* Dark Amber background */
    border-color: #665510 !important;
}
/* Fix the label color inside that box */
body.pew-dark-mode .pew-data-point[style*="background:#fcf8e3"] label {
    color: #f5d680 !important; /* Muted Gold */
}

/* --- FIX ROUNDS/VALUE BOX IN NIGHT MODE --- */
/* Target the div by its specific inline background color */
body.pew-dark-mode div[style*="background:#f8f9fa"] {
    background-color: #2b2b2b !important; /* Dark Grey */
    border-color: #444 !important;
}

/* Fix the labels inside (Rounds:, Value:) */
body.pew-dark-mode div[style*="background:#f8f9fa"] span {
    color: #aaa !important;
}

/* Fix the Value number (Keep it green but readable) */
body.pew-dark-mode div[style*="background:#f8f9fa"] strong[style*="color:#28a745"] {
    color: #4cd16f !important; /* Lighter/Brighter Green for Dark Mode */
}

/* --- FIX NIGHT MODE: LOGS & ACCESSORIES --- */

/* 1. Range Log Form Container */
/* Overrides inline background:#f9f9f9 */
body.pew-dark-mode #form-add-log[style] {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
}

/* 2. Range Log Dropzone */
/* Overrides inline background:#fff and dashed border */
body.pew-dark-mode #dropzone-log[style] {
    background-color: #2d2d2d !important;
    border-color: #555 !important;
}
/* Fix text/icons inside the dropzone */
body.pew-dark-mode #dropzone-log p,
body.pew-dark-mode #dropzone-log i {
    color: #aaa !important;
}

/* 3. Accessory Row Thumbnail Placeholder */
/* Targets the empty box with the chain link icon */
body.pew-dark-mode .pew-accessory-row div[style*="background:#eee"] {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    color: #fff !important;
}

/* 4. Accessory Links */
body.pew-dark-mode .pew-accessory-row a {
    color: #76b041 !important; /* Tactical Green */
}

/* 5. The "Delete Accessory" (X) Button */
/* Make it a lighter red so it's visible on dark gray */
body.pew-dark-mode .btn-del-acc {
    color: #ff6b6b !important;
}

/* --- FIX ACCESSORY ROW IN NIGHT MODE --- */

/* 1. The Thumbnail Box */
/* Targets the specific 30x30 box used for the icon/image */
body.pew-dark-mode .pew-accessory-row div[style*="width:30px"] {
    background-color: #2d2d2d !important; /* Dark Gray Background */
    border-color: #444 !important;         /* Dark Border */
    color: #fff !important;                /* Icon color */
}

/* 2. The Text (Name of the item) */
body.pew-dark-mode .pew-accessory-row h4 {
    color: #e0e0e0 !important;
}

/* 3. The Link ("View Item") */
body.pew-dark-mode .pew-accessory-row .pew-acc-link {
    color: #76b041 !important; /* Tactical Green */
}

/* 4. The Delete Button (X) */
/* Changes "Red" to "Soft Red" so it doesn't vibrate on the dark background */
body.pew-dark-mode .pew-accessory-row .btn-del-acc {
    color: #ff6b6b !important;
}

/* 5. The Row Container (Optional hover effect) */
body.pew-dark-mode .pew-accessory-row:hover {
    background-color: #252525; /* Subtle highlight on hover */
    border-radius: 4px;
}

/* --- FIX ACCESSORY ROW BACKGROUND --- */
body.pew-dark-mode .pew-accessory-row {
    background-color: transparent !important; /* Remove the white background */
    border-bottom: 1px solid #333 !important; /* Optional: adds a subtle divider */
    color: #e0e0e0 !important;
}

/* Ensure the text inside is always visible */
body.pew-dark-mode .pew-accessory-row h4 {
    color: #fff !important;
}

/* Fix the cost/price text if it exists */
body.pew-dark-mode .pew-accessory-row span[style*="color:#28a745"] {
    color: #4cd16f !important; /* Lighter green for readability */
}

/* --- DASHBOARD CARD ACTIONS (Fixed Selector) --- */

/* 1. Layout: Push View to Left, Archive to Right */
.pew-card-actions {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center;
    background-color: #f8f9fa; /* Light Mode bg */
    padding: 10px 15px;
    border-top: 1px solid #eee;
    border-radius: 0 0 8px 8px; /* Rounded corners at bottom */
}

/* 2. Night Mode Fix */
body.pew-dark-mode .pew-card-actions {
    background-color: #252525 !important; /* Dark Gray */
    color: #FFF !important;
    border-color: #333 !important;
}

/* 3. View Button Style */
.pew-btn-view {
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}
.pew-btn-view:hover {
    background-color: #c2c2c2;
    color: #76b041 !important;
}

/* Night Mode View Button */
body.pew-dark-mode .pew-btn-view {
    background-color: #76b041; /* Tactical Green */
    color: #FFF !important;
}

#pew-theme-toggle {
    position: relative;
    z-index: 9999; /* Ensure it sits on top of mobile headers */
    cursor: pointer;
}

/* =========================================
   13. AMMO DUMP DARK MODE FIXES
   ========================================= */

/* Override the inline styles on the container */
body.pew-dark-mode #pew-ammo-form {
    background-color: #1e1e1e !important; /* Dark Gray Background */
    border-color: #a84300 !important;     /* Darker Orange Border */
    color: #e0e0e0 !important;            /* Light Text */
}

/* Fix the Title (Keep it orange but readable) */
body.pew-dark-mode #pew-ammo-form h3 {
    color: #e67e22 !important;
}

/* Fix the Inputs inside the Ammo Form */
body.pew-dark-mode #pew-ammo-form input {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    color: #fff !important;
}

/* Fix Placeholder text in inputs */
body.pew-dark-mode #pew-ammo-form input::placeholder {
    color: #888 !important;
}

/* =========================================
   14. COMMAND CENTER (STATS DECK)
   ========================================= */
.pew-stat-deck {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
}

.pew-stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid #e0e0e0;
    border-bottom: 4px solid #ddd;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.pew-stat-icon {
    font-size: 32px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f4;
    border-radius: 50%;
}

.pew-stat-info {
    display: flex;
    flex-direction: column;
}

.pew-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    font-weight: 700;
}

.pew-stat-value {
    font-size: 22px;
    font-weight: 800;
    color: #2c3e50;
}

/* Colors */
.pew-stat-card.card-money { border-bottom-color: #27ae60; }
.pew-stat-card.card-money .pew-stat-icon { background-color: #eafaf1; color: #27ae60; }

.pew-stat-card.card-rounds { border-bottom-color: #e67e22; }
.pew-stat-card.card-rounds .pew-stat-icon { background-color: #fdf2e9; color: #e67e22; }

.pew-stat-card.card-units { border-bottom-color: #2980b9; }
.pew-stat-card.card-units .pew-stat-icon { background-color: #ebf5fb; color: #2980b9; }

/* Dark Mode */
body.pew-dark-mode .pew-stat-card {
    background: #1e1e1e;
    border-color: #333;
}
body.pew-dark-mode .pew-stat-value { color: #fff; }
body.pew-dark-mode .pew-stat-label { color: #aaa; }
body.pew-dark-mode .pew-stat-icon { background-color: #2d2d2d; }
/* =========================================
   12. MOBILE OPTIMIZATIONS (Phones & Tablets)
   ========================================= */
@media screen and (max-width: 768px) {

    /* --- FIX 1: TOOLBAR LAYOUT --- */
    /* Break the main row into a column */
    #pew-locker-wrapper > div[style*="display:flex; justify-content:space-between"] {
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Tabs: Full Width Row */
    .pew-tabs {
        display: flex !important;
        width: 100%;
        border: 1px solid var(--pew-border);
        border-radius: 4px;
        overflow: hidden;
    }
    .pew-tabs a {
        flex: 1;
        text-align: center;
        border: none !important;
        border-right: 1px solid var(--pew-border) !important;
        padding: 10px;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    .pew-tabs a:last-child { border-right: none !important; }

    /* Right Action Group: Wrap it */
    #pew-locker-wrapper > div > div[style*="margin-left:auto"] {
        margin-left: 0 !important;
        width: 100%;
        display: flex;
        flex-wrap: wrap; /* Allow wrapping */
        gap: 10px;
    }

    /* Search Bar: Top Row, Full Width */
    #pew-live-search {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        order: 1; /* First */
    }

    /* Dropdown: Bottom Left, Grow */
    #pew-cat-filter {
        order: 2;
        flex-grow: 1;
        width: auto !important;
        margin: 0 !important;
        height: 40px !important;
    }

    /* Toggle Buttons: Bottom Right, Fixed */
    .pew-view-toggle {
        order: 3;
        margin: 0 !important;
    }
    .pew-view-btn {
        width: 40px !important;
        height: 40px !important;
    }

    /* --- FIX 2: COMPACT LIST VIEW --- */
    #pew-inventory-grid.list-view {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    #pew-inventory-grid.list-view .pew-card {
        flex-direction: row !important;
        min-height: 80px;
        height: auto;
        align-items: center;
        padding: 0;
    }

    #pew-inventory-grid.list-view .pew-card-img {
        width: 80px !important;
        height: 80px !important;
        flex-shrink: 0;
        border-right: 1px solid #eee;
        border-bottom: none !important;
        margin: 0;
    }

    #pew-inventory-grid.list-view .pew-card-body {
        padding: 10px 15px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
    }

    #pew-inventory-grid.list-view h3 {
        font-size: 16px;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 180px;
    }

    #pew-inventory-grid.list-view .pew-card-actions {
        display: none !important;
    }

    /* Mobile Swipe Hint */
        .pew-swipe-hint {
            display: block;
            text-align: center;
            font-size: 11px;
            color: #888;
            margin-bottom: 2px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

/* --- FIX 3: ITEM DETAIL HEADER STACK --- */
    /* Forces the Title and Buttons to stack vertically on mobile */
    .pew-detail-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px;
    }

    /* Optional: Make buttons wrap if there are too many */
    .pew-detail-header .pew-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    /* --- GENERAL MOBILE FORM FIXES --- */
    input, select, textarea {
        font-size: 16px !important; /* Prevents iOS Zoom */
    }
}