/* ========================================
   Custom Image Cropper - Styles (Updated)
   ======================================== */

:root {
    --cic-primary: #2563eb;
    --cic-primary-hover: #1d4ed8;
    --cic-success: #16a34a;
    --cic-border: #e5e7eb;
    --cic-bg: #f9fafb;
    --cic-text: #111827;
    --cic-text-muted: #6b7280;
    --cic-radius: 10px;
    --cic-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ---------- Wrapper ---------- */
.cic-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--cic-text);
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--cic-shadow);
}

/* ---------- Header ---------- */
.cic-header {
    text-align: center;
    margin-bottom: 24px;
}

.cic-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
}

.cic-subtitle {
    margin: 0;
    color: var(--cic-text-muted);
    font-size: 0.95rem;
}

/* ---------- Upload Section ---------- */
.cic-upload-section {
    margin-bottom: 20px;
}

.cic-upload-box {
    border: 2px dashed #cbd5e1;
    border-radius: var(--cic-radius);
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: var(--cic-bg);
}

.cic-upload-box:hover,
.cic-upload-box.dragover {
    border-color: var(--cic-primary);
    background: #eff6ff;
}

.cic-upload-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.cic-upload-box p {
    margin: 6px 0;
    font-size: 1rem;
    color: #111827;
}

.cic-upload-hint {
    font-size: 0.85rem !important;
    color: var(--cic-text-muted);
}

/* ---------- Workspace Layout ---------- */
.cic-workspace {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.cic-canvas-area {
    flex: 1 1 580px;
    min-width: 0;
}

.cic-controls-panel {
    flex: 0 0 300px;
    background: var(--cic-bg);
    border-radius: var(--cic-radius);
    padding: 20px;
    border: 1px solid var(--cic-border);
}

/* ---------- Canvas Container ---------- */
.cic-canvas-container {
    position: relative;
    width: 100%;
    height: 480px;
    background: #1f2937;
    border-radius: var(--cic-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.cic-canvas-container:active {
    cursor: grabbing;
}

#cic-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* ---------- Zoom Controls ---------- */
.cic-zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.cic-zoom-controls input[type="range"] {
    width: 140px;
    cursor: pointer;
}

#cic-zoom-value {
    font-size: 0.9rem;
    min-width: 48px;
    text-align: center;
    color: var(--cic-text-muted);
}

/* ---------- Buttons ---------- */
.cic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 11px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cic-btn-primary {
    background: var(--cic-primary);
    color: #fff;
}

.cic-btn-primary:hover {
    background: var(--cic-primary-hover);
}

.cic-btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.cic-btn-secondary:hover {
    background: #d1d5db;
}

.cic-btn-preview {
    background: var(--cic-success);
    color: #fff;
    margin-bottom: 12px;
}

.cic-btn-preview:hover {
    background: #15803d;
}

.cic-btn-download {
    background: #111827;
    color: #fff;
    margin-bottom: 8px;
}

.cic-btn-download:hover {
    background: #000;
}

.cic-btn-reset {
    background: transparent;
    color: var(--cic-text-muted);
    border: 1px solid var(--cic-border);
    margin-top: 8px;
}

.cic-btn-reset:hover {
    background: #f3f4f6;
    color: #111827;
}

.cic-btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--cic-border);
    background: #fff;
    border-radius: 8px;
    font-size: 1.2rem;
    color: #111827;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cic-btn-icon:hover {
    background: #f3f4f6;
}

.cic-check-icon {
    font-weight: 700;
}

/* ---------- Control Groups ---------- */
.cic-control-group {
    margin-bottom: 20px;
}

.cic-control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #111827;
}

/* Unit Switcher - FIXED COLORS */
.cic-unit-switcher {
    display: flex;
    gap: 6px;
}

.cic-unit-btn {
    flex: 1;
    padding: 8px 0;
    border: 1px solid var(--cic-border);
    background: #ffffff;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #111827;          /* Dark text - FIXED */
    cursor: pointer;
    transition: all 0.2s;
}

.cic-unit-btn.active {
    background: var(--cic-primary);
    color: #ffffff;
    border-color: var(--cic-primary);
}

.cic-unit-btn:hover:not(.active) {
    background: #f3f4f6;
    color: #111827;
}

/* Size Inputs */
.cic-size-inputs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.cic-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--cic-border);
    border-radius: 8px;
    overflow: hidden;
}

.cic-input-wrap span {
    padding: 0 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #4b5563;
    background: #f3f4f6;
    height: 100%;
    display: flex;
    align-items: center;
}

.cic-input-wrap input {
    width: 100%;
    border: none;
    padding: 10px;
    font-size: 0.95rem;
    color: #111827;
    outline: none;
    background: #fff;
}

/* Quality Slider */
#cic-quality-slider {
    width: 100%;
    margin: 8px 0;
    cursor: pointer;
}

.cic-quality-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--cic-text-muted);
}

#cic-quality-kb {
    font-weight: 500;
    color: var(--cic-primary);
}

/* Download Group */
.cic-download-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---------- Preview Modal ---------- */
.cic-preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.cic-preview-content {
    background: #fff;
    border-radius: 14px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.cic-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cic-border);
}

.cic-preview-header h3 {
    margin: 0;
    font-size: 1.15rem;
    color: #111827;
}

/* Close button - FIXED */
#cic-close-preview {
    width: 36px;
    height: 36px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 8px;
    font-size: 1.2rem;
    color: #111827;          /* Dark color - FIXED */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cic-close-preview:hover {
    background: #f3f4f6;
}

.cic-preview-body {
    padding: 20px;
    text-align: center;
    background: #f3f4f6;
}

#cic-preview-image {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 8px;
    box-shadow: var(--cic-shadow);
}

.cic-preview-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--cic-border);
}

/* Info text for physical size */
.cic-size-info {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 6px;
    line-height: 1.4;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .cic-workspace {
        flex-direction: column;
    }

    .cic-controls-panel {
        flex: 1 1 auto;
        width: 100%;
    }

    .cic-canvas-container {
        height: 360px;
    }
}

@media (max-width: 480px) {
    .cic-wrapper {
        padding: 14px;
        border-radius: 12px;
    }

    .cic-title {
        font-size: 1.3rem;
    }

    .cic-canvas-container {
        height: 280px;
    }

    .cic-zoom-controls input[type="range"] {
        width: 100px;
    }

    .cic-unit-btn {
        font-size: 0.8rem;
        padding: 7px 0;
    }
}