#cip-app {
    margin-top: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Frontend Specific Styles */
.cip-frontend { margin: 0; padding: 1em 0; box-shadow: none; border: none; }
.cip-frontend #cip-lifetime-stats,
.cip-frontend .setting-group[data-setting-group="after-upload"],
.cip-frontend .setting-group[data-setting-group="after-download"] input[value="none"],
.cip-frontend label[for*="cip-after-upload"],
.cip-frontend #cip-upload-processed,
.cip-frontend #cip-reset-lifetime-stats,
.cip-frontend #cip-load-from-media /* Hide media load button in frontend */
{ display: none !important; }


#cip-app hr { margin: 25px 0; border: none; border-top: 1px solid #dcdcde; }

/* Accordion Styles */
details.cip-accordion { border: 1px solid #c3c4c7; border-radius: 3px; margin-bottom: 15px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.04);}
details.cip-accordion[open] { border-bottom: 1px solid #c3c4c7; }
details.cip-accordion summary { padding: 10px 15px; font-weight: 600; color: #1d2327; cursor: pointer; background: #f6f7f7; border-bottom: 1px solid transparent; list-style: none; display: flex; align-items: center; justify-content: space-between; transition: background-color 0.1s ease; }
details.cip-accordion[open] summary { border-bottom-color: #e5e5e5; background: #f0f0f1; }
details.cip-accordion summary:hover { background: #f0f0f1; }
details.cip-accordion summary::-webkit-details-marker { display: none; }
details.cip-accordion summary::after { content: '\f140'; font-family: dashicons; font-size: 20px; color: #50575e; transition: transform 0.2s ease-in-out; margin-left: 10px; }
details.cip-accordion[open] summary::after { transform: rotate(180deg); }
.cip-accordion-content { padding: 15px; border-top: 1px solid #e5e5e5;}

/* Upload Area */
#cip-uploader-details summary { background: none; border: none; padding: 5px 0; }
#cip-uploader-details[open] summary { border-bottom: 1px solid #e5e5e5; margin-bottom: 10px; }
#cip-drop-zone { border: 2px dashed #c3c4c7; padding: 30px; text-align: center; background-color: #f6f7f7; border-radius: 4px; transition: background-color 0.2s ease, border-color 0.2s ease; margin-top: 10px; position: relative; }
#cip-drop-zone.drag-over { background-color: #e0e5e9; border-color: #949ca1; }
#cip-drop-zone p { margin: 0; color: #50575e; }
#cip-file-input-label { color: #007cba; text-decoration: underline; cursor: pointer; }
#cip-file-input-label:hover { color: #005a87; }
#cip-drop-zone #cip-loading-spinner { position: absolute; top: 10px; right: 10px; }


/* Spinner Style & Fallback */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(0, 124, 186, 0.3); border-radius: 50%; border-top-color: #007cba; animation: spin 1s ease-in-out infinite; -webkit-animation: spin 1s ease-in-out infinite; visibility: hidden; }
.spinner.is-active { visibility: visible; }

/* Session Stats */
#cip-session-stats { border: 1px solid #c3c4c7; color: #3c434a; }
#cip-session-stats strong { margin-right: 10px; color: #1d2327; }
#cip-session-stats .stat-item { margin-right: 15px; display: inline-block; margin-bottom: 5px;}
#stat-session-formats { font-style: italic; color: #50575e;}

/* Main Layout: Previews & Sidebar */
#cip-main-content-area { display: flex; flex-wrap: wrap; gap: 30px; margin-top: 20px; display: none; /* Initially hidden */}
#cip-previews-wrapper { flex: 3 1 600px; min-width: 300px; }
#cip-sidebar { flex: 1 1 300px; min-width: 280px; max-width: 360px; /* Max width set */ }

/* Controls & Settings Area within Sidebar */
#cip-sidebar h2 { font-size: 1.3em; margin-bottom: 15px; padding-bottom: 5px; border-bottom: 1px solid #e0e0e0; font-weight: 600; color: #1d2327; }
#cip-sidebar h3 { margin-top: 0; margin-bottom: 15px; font-size: 1.1em; color: #1d2327; font-weight: 600; }
#cip-sidebar label { margin-bottom: 3px; font-weight: normal; color: #3c434a; display: inline-block; vertical-align: middle;}
#cip-sidebar input[type="number"], #cip-sidebar select { padding: 5px 8px; border-radius: 3px; border: 1px solid #8c8f94; width: 100%; box-sizing: border-box; margin-bottom: 10px;}
#cip-sidebar input[type="number"]#cip-quality { width: 60px; display: inline-block; margin-left: 5px; margin-bottom: 0; vertical-align: middle;}
#cip-sidebar select#cip-convert-format { display: inline-block; width: auto; margin-bottom: 0; vertical-align: middle;}
#cip-sidebar input[type="radio"] { margin-right: 5px; vertical-align: -2px; }
#cip-sidebar .setting-group { margin-bottom: 15px; }
#cip-sidebar .setting-group label { display: block; margin-right: 0; margin-bottom: 5px; }
#cip-sidebar .setting-group strong { display: block; margin-bottom: 5px; font-weight: 600; }
#cip-sidebar .setting-group small { font-size: 11px; color: #787c82; margin-left: 5px; }
#cip-actions-buttons .button { width: 100%; text-align: center; margin-bottom: 5px; margin-right: 0;}
#cip-save-download-buttons .button { width: 100%; text-align: center; margin-right: 0;}
#cip-actions-buttons h3, #cip-save-download-buttons h3 { margin-top: 20px; }
#cip-log-sidebar h3 { margin-top: 0;}


/* Image Grid & Tiles */
.cip-category-container { margin-bottom: 30px; border: 1px solid #ccd0d4; padding: 15px; background-color: #f6f7f7; border-radius: 4px; }
.cip-category-container h2 { margin-top: 0; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #ccd0d4; display: flex; justify-content: space-between; align-items: center; font-size: 1.3em; }
.cip-grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 250px)); gap: 20px; } /* Applied max width */
.cip-tile { position: relative; border: 1px solid #ddd; background-color: #fff; display: flex; flex-direction: column; overflow: hidden; transition: opacity 0.3s ease, filter 0.3s ease, max-height 0.35s ease-in-out, margin 0.35s ease-in-out, padding 0.35s ease-in-out, border 0.35s ease-in-out; box-shadow: 0 1px 2px rgba(0,0,0,0.1); border-radius: 3px; }
.cip-tile.uploaded-gray, .cip-tile.downloaded-gray { filter: grayscale(90%); opacity: 0.6; }
.cip-tile.uploaded-hide, .cip-tile.downloaded-hide { opacity: 0; pointer-events: none; max-height: 0 !important; overflow: hidden; border: none !important; margin: 0 !important; padding: 0 !important; }
.cip-tile-image-wrapper { position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; background-color: #eee; }
.cip-tile img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center center; }
.cip-tile .cip-checkbox { position: absolute; top: 5px; left: 5px; z-index: 10; background-color: rgba(255, 255, 255, 0.7); border-radius: 3px; padding: 2px; transform: scale(1.2); cursor: pointer; }
.cip-tile-info { padding: 8px 10px; font-size: 11px; line-height: 1.45; background-color: #fdfdfd; border-top: 1px solid #eee; min-height: 65px; color: #50575e; flex-grow: 1; }
.cip-tile-info strong { color: #1d2327; }
.cip-tile-info .info-before, .cip-tile-info .info-after { display: block; margin-bottom: 4px; word-wrap: break-word; }
.cip-tile-info .info-after { margin-top: 4px; }
.cip-tile-info .info-reduction { color: #006799; font-weight: bold; margin-left: 3px; }
.cip-tile-info .no-reduction { color: #787c82; margin-left: 3px; }
.cip-tile .cip-status-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255, 255, 255, 0.75); display: flex; justify-content: center; align-items: center; font-size: 1em; font-weight: bold; color: #1d2327; z-index: 5; text-align: center; padding: 5px; opacity: 0; transition: opacity 0.3s ease; pointer-events: none; border-radius: 3px 3px 0 0; }
.cip-tile .cip-status-overlay.visible { opacity: 1; }
.cip-tile .cip-status-overlay.processing { color: #0073aa; background-color: rgba(240, 246, 252, 0.8); }
.cip-tile .cip-status-overlay.success { background-color: rgba(0, 167, 98, 0.85); color: white; }
.cip-tile .cip-status-overlay.error { background-color: rgba(220, 50, 50, 0.85); color: white; }
.cip-tile .cip-status-overlay.uploaded { background-color: rgba(114, 119, 124, 0.85); color: white; }
.cip-tile .cip-status-overlay.downloaded { background-color: rgba(114, 119, 124, 0.85); color: white; }
.cip-tile.processing .cip-tile-image-wrapper { opacity: 0.7; }

/* Button Styling */
#cip-upload-processed, #cip-download-zip, #cip-reset-lifetime-stats, .cip-action-button, #cip-refresh-images, #cip-clear-all { transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, opacity 0.2s ease-in-out; margin-right: 0; margin-bottom: 5px; }
#cip-upload-processed { background-color: #2271b1; color: white; border-color: #1f6aa1; }
#cip-upload-processed:hover { background-color: #1f6aa1; border-color: #1a5a8e; color: white; }
#cip-download-zip { background-color: #3c434a; color: white; border-color: #32373c; }
#cip-download-zip:hover { background-color: #32373c; border-color: #2a2f33; color: white; }
.cip-action-button { background-color: #f0f0f1; border-color: #8c8f94; color: #1d2327;}
.cip-action-button:hover { background-color: #e0e1e3; border-color: #6a6e73;}
.cip-action-button.button-primary { background-color: #007cba; color: white; border-color: #0071a1;}
.cip-action-button.button-primary:hover { background-color: #006ba1; border-color: #005a87;}
#cip-reset-lifetime-stats, #cip-clear-all { background-color: #d63638; color: white; border-color: #b62f2f; }
#cip-reset-lifetime-stats:hover, #cip-clear-all:hover { background-color: #b62f2f; border-color: #a0292a; }
#cip-refresh-images { background-color: #f0f0f1; border-color: #8c8f94; color: #1d2327;}
#cip-refresh-images:hover { background-color: #e0e1e3; border-color: #6a6e73;}
#cip-upload-processed:disabled, #cip-download-zip:disabled, #cip-reset-lifetime-stats:disabled, .cip-action-button:disabled, #cip-refresh-images:disabled, #cip-clear-all:disabled { background-color: #a7aaad !important; border-color: #9a9c9f !important; color: #eaeaec !important; cursor: not-allowed !important; opacity: 0.7 !important; }

/* Lifetime Stats */
#cip-lifetime-stats { font-size: 13px; border: 1px solid #c3c4c7; color: #3c434a; }
#cip-lifetime-stats h3 { margin-bottom: 10px; color: #1d2327;}
#cip-lifetime-stats ul { margin-top: 5px; margin-bottom: 10px; margin-left: 20px; list-style: disc; }
#cip-lifetime-stats p { margin: 5px 0; }
#cip-lifetime-stats strong { color: #1d2327; }
#cip-lifetime-stats small { color: #787c82; font-size: 11px; }
#cip-lifetime-stats-content.loading { color: #787c82; font-style: italic; }

/* Media Modal Styles (Backend only) */
#cip-media-modal { display: none; position: fixed; z-index: 10000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); }
.cip-modal-content { background-color: #fefefe; margin: 5% auto; padding: 20px; border: 1px solid #888; width: 80%; max-width: 700px; border-radius: 4px; box-shadow: 0 5px 15px rgba(0,0,0,.5); }
.cip-modal-close { color: #aaa; float: right; font-size: 28px; font-weight: bold; }
.cip-modal-close:hover, .cip-modal-close:focus { color: black; text-decoration: none; cursor: pointer; }
#cip-media-breadcrumbs { margin-bottom: 15px; font-size: 14px; }
#cip-media-breadcrumbs a { text-decoration: none; color: #0073aa; }
#cip-media-breadcrumbs a:hover { text-decoration: underline; }
#cip-media-breadcrumbs span { margin: 0 5px; }
#cip-media-folder-list ul, #cip-media-image-list ul { list-style: none; padding: 0; margin: 0; }
#cip-media-folder-list li a { display: block; padding: 8px 10px; text-decoration: none; color: #0073aa; border-bottom: 1px solid #eee; }
#cip-media-folder-list li a:hover { background-color: #f0f0f0; }
#cip-media-folder-list li a::before { font-family: dashicons; content: "\f157"; margin-right: 8px; } /* Folder icon */
#cip-media-image-list li { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid #eee; }
#cip-media-image-list li:last-child { border-bottom: none; }
#cip-media-image-list input[type="checkbox"] { margin-right: 10px; }
#cip-media-image-list img.thumbnail { width: 40px; height: 40px; object-fit: cover; margin-right: 10px; border: 1px solid #ddd; }
#cip-media-image-list .filename { flex-grow: 1; }
#cip-media-image-list .filesize { font-size: 12px; color: #777; margin-left: 10px; }
#cip-media-modal-actions { margin-top: 20px; text-align: right; }