.ric-app-wrapper *,
.ric-app-wrapper *::before,
.ric-app-wrapper *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.ric-app-wrapper {
    color: #2c3e50;
    line-height: 1.6;
    padding: 20px;
    margin-bottom: 40px;
}

.ric-container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.ric-container.is-narrow {
    max-width: 700px;
}

.ric-main-title {
    text-align: center;
    color: #2c3e50;
    font-size: 29px;
    font-weight: 500;
    margin-top: 15px;
}

.ric-progress-view {
    padding: 20px 20px 35px 20px;
}

.ric-progress-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    margin-top: 10px;
    padding: 0 10px;
}

.ric-progress-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #4a6cf7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

.ric-progress-container {
    flex-grow: 1;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.ric-progress-bar-inner {
    height: 100%;
    width: 0%;
    background-color: #4a6cf7;
    transition: width 0.1s linear;
    border-radius: 10px;
}

.ric-progress-percentage-text {
    font-weight: 500;
    margin-left: 10px;
}

.ric-animated-loading-text {
    text-align: center;
    font-size: 17px;
    color: #5a6a7a;
    height: 20px;
}

.ric-content {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.ric-initial-selection {
    padding: 10px 20px 35px 20px;
}

.ric-selection-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 2px dashed #dce1e9;
    border-radius: 12px;
    text-align: center;
    background-color: #f9fafc;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    max-width: 600px;
    margin: 0 auto;
    line-height: 0.7;
    position: relative;
}

.ric-selection-box.loading .ric-selection-content {
    opacity: 0.5;
    pointer-events: none;
}

.ric-selection-box.drag-over {
    background-color: #e9f2ff;
    border-color: #4a6cf7;
}

.ric-selection-box p {
    color: #5a6a7a;
    font-size: 18px;
    margin-bottom: 0;
    text-align: center;
}

.ric-selection-box .ric-selection-or {
    margin: 15px 0;
}

@media (min-width: 992px) {
    .ric-content {
        flex-direction: row;
    }
}

.ric-preview-section {
    flex: 1.4;
    padding: 0 20px;
}

.ric-controls-section {
    flex: 1;
    padding: 20px;
    background: #f9fafc;
    border-radius: 10px;
}

.ric-section-title {
    font-size: 21px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eaeef5;
    color: #2c3e50;
    font-weight: 500;
}

.ric-control-group {
    margin-bottom: 25px;
}

.ric-control-label {
    display: block;
    margin-bottom: 1px;
    font-weight: 500;
    color: #34495e;
}

.ric-dimension-inputs {
    display: flex;
    gap: 9px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 20px;
}

.ric-dimension-input {
    width: 100px;
    padding: 9px;
    border: 1px solid #dce1e9;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
    background-color: #ffffff;
}

.ric-dimension-input:focus {
    outline: none;
    background-color: #ffffff;
    border-color: #4a6cf7;
    box-shadow: 0 0 0 1px rgba(74, 108, 247, 0.1);
}

.ric-dimension-input[type="number"]::-webkit-inner-spin-button,
.ric-dimension-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Hide number input spinners */
.ric-dimension-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
    background-color: #ffffff;
    border: 1px solid #dce1e9;
    border-radius: 6px;
}

select.ric-dimension-input {
    width: auto;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 20px 20px;
    padding-right: 40px;
    /* Make space for icon */
    cursor: pointer;
}

.ric-app-wrapper .ric-dimension-input:hover,
.ric-app-wrapper .ric-dimension-input:active {
    background-color: #ffffff;
}

.ric-app-wrapper .ric-dimension-input:focus {
    background-color: #ffffff;
}

.ric-checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.ric-checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.ric-checkbox-group input[type="checkbox"]:focus,
.ric-shape-selector input[type="radio"]:focus {
    outline: none;
}

.aspect-ratio-presets {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.ric-control-btn {
    padding: 10px 16px;
    background: white;
    border: 1px solid #dce1e9;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.ric-control-btn:hover {
    background: #f1f5fd;
    border-color: #4a6cf7;
}

.ric-control-btn.active {
    background: #4a6cf7;
    color: white;
    border-color: #4a6cf7;
}

.ric-slider {
    width: 100%;
    margin: 15px 0;
}

.ric-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ric-slider-container .ric-slider {
    margin: 0;
    flex: 1;
    /* Allow the slider to take up remaining space without overflowing */
}

.ric-slider-container .ric-slider-value {
    font-weight: 500;
    margin-left: 2px;
    /* Add a minimal space after the slider */
    flex-shrink: 0;
    text-align: right;
}

.ric-rotate-btn {
    margin-left: 8px;
    /* Add space before the button */
    padding: 8px 12px;
    background: white;
    border: 1px solid #dce1e9;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #34495e;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ric-rotate-btn:hover,
.ric-rotate-btn:focus {
    background: white;
    color: #34495e;
    border-color: #4a6cf7;
    outline: none;
}

.ric-rotate-btn:active {
    transform: scale(0.95);
    background-color: white;
}

.ric-action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.ric-mobile-toggle {
    display: none;
    /* Hidden by default, shown on mobile */
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.ric-mobile-toggle:hover,
.ric-mobile-toggle:focus {
    background-color: #f9fafc;
    color: #34495e;
    /* Prevent theme hover */
    outline: none;
}

.ric-mobile-toggle:active {
    transform: scale(0.98);
}

.ric-toggle-icon {
    transition: transform 0.3s ease;
}

.ric-mobile-toggle[aria-expanded="true"] .ric-toggle-icon {
    transform: rotate(180deg);
}

.ric-btn {
    padding: 9px 13px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
}

.ric-btn-primary {
    background: #4b6ae5;
    color: white;
}

.ric-btn-primary:hover,
.ric-btn-primary:focus {
    background: #4b6ae5;
    box-shadow: 0 4px 10px rgba(74, 108, 247, 0.3);
    outline: none;
}

.ric-btn-primary:active {
    background: #4b6ae5;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(74, 108, 247, 0.2);
    outline: none;
}

.ric-btn-secondary {
    background: #6c757d;
    color: white;
}

.ric-btn-secondary:hover,
.ric-btn-secondary:focus {
    background: #6c757d;
    box-shadow: 0 4px 10px rgba(108, 117, 125, 0.3);
    outline: none;
}

.ric-btn-secondary:active {
    background: #6c757d;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(108, 117, 125, 0.2);
    outline: none;
}

.ric-btn-success {
    background: #198754;
    color: white;
}

.ric-btn-success:hover,
.ric-btn-success:focus {
    background: #198754;
    box-shadow: 0 4px 10px rgba(25, 135, 84, 0.3);
    outline: none;
}

.ric-btn-success:active {
    background: #198754;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(25, 135, 84, 0.2);
    outline: none;
}

.ric-btn-info {
    background: #0f8198;
    color: white;
}

.ric-btn-info:hover,
.ric-btn-info:focus {
    background: #0f8198;
    box-shadow: 0 4px 10px rgba(13, 202, 240, 0.3);
    outline: none;
}

.ric-btn-info:active {
    background: #0f8198;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(13, 202, 240, 0.2);
    outline: none;
}

.ric-btn-danger {
    background: #dc3545;
    color: white;
}

.ric-btn-danger:hover,
.ric-btn-danger:focus {
    background: #dc3545;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
    outline: none;
}

.ric-btn-danger:active {
    background: #dc3545;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 5px rgba(220, 53, 69, 0.2);
    outline: none;
}

.ric-btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ric-btn.loading .ric-btn-text {
    margin-right: 10px;
}

.ric-btn.loading .ric-btn-loader {
    display: inline-block;
}

.ric-crop-area {
    width: 100%;
    height: 400px;
    background-color: #f9f9f9;
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #eaeef5;
    /* position: relative; */
    /* No longer needed */
}

#ric-image-to-crop {
    display: block;
    max-width: 100%;
}

.ric-result-container {
    margin-top: 30px;
    padding: 25px;
    background: #f9fafc;
    border-radius: 10px;
    text-align: center;
}

.ric-result-image {
    max-width: 100%;
    max-height: 200px;
    /* Limit height for multiple images */
    margin-right: 10px;
    /* Add space between multiple result images */
    margin-bottom: 10px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    margin-top: 15px;
}

.ric-shape-selector {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin: 15px 0;
}

.ric-shape-selector label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #34495e;
}

.ric-shape-selector input[type="radio"] {
    width: 18px;
    height: 18px;
}

.ric-image-nav {
    color: #34495e;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    user-select: none;
    margin-bottom: 10px;
    display: none;
}

#ric-image-counter {
    font-size: 18px;
    font-weight: 500;
    min-width: 50px;
    /* Prevents layout shift when counter changes (e.g., 9/10 to 10/10) */
    text-align: center;
}

#ric-prev-image-btn {
    transform: scaleX(-1);
    /* Flip the icon horizontally */
}

.ric-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    color: #5a6a7a;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
}

.ric-app-wrapper .ric-nav-btn:hover,
.ric-app-wrapper .ric-nav-btn:focus {
    background-color: #ffffff;
    color: #5a6a7a;
    border-color: #dee2e6;
    outline: none;
}

.ric-nav-btn:active {
    transform: scale(0.9);
}

#ric-prev-image-btn:active {
    transform: scaleX(-1) scale(0.9);
    /* Combine flip and click effect */
}

.ric-nav-btn:disabled {
    color: #bdc3c7;
}

/* Loading spinner */
.ric-spinner {
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4a6cf7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
    /* JS will toggle this */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.ric-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 5px 13px;
    background: #4a6cf7;
    color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.ric-toast.show {
    opacity: 1;
}

/* --- Custom Cropper Styles --- */
#ric-cropper-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #f0f0f0;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    display: none;
    /* Hidden until image is loaded */
}

#ric-cropper-container.active {
    cursor: grabbing;
}

#ric-cropper-canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.ric-crop-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    text-align: center;
    border: 2px dashed #ccc;
}

.ric-result-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 10px;
    text-align: center;
}

.ric-result-message {
    font-size: 19px;
    font-weight: 500;
    color: #198754;
    /* Success color */
    margin-bottom: 25px;
}

.ric-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.ric-success-icon {
    width: 50px;
    height: 50px;
    color: #198754;
    /* Success color */
    margin-bottom: 15px;
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 18px;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .ric-app-wrapper {
        padding-left: 0;
        padding-right: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

    .ric-container {
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid #e0e0e0;
        border-bottom: 1px solid #e0e0e0;
        max-width: none;
        /* Allow full width */
        margin: 0;
    }

    .ric-content,
    .ric-initial-upload {
        padding-left: 0;
        padding-right: 0;
    }

    .ric-preview-section {
        padding: 0;
    }

    .ric-controls-section {
        padding-top: 20px;
        padding-left: 0;
        padding-right: 0;
        background: none;
    }

    .ric-mobile-toggle {
        display: flex;
        width: 100%;
        padding: 12px 20px;
        background-color: #f9fafc;
        border: 1px solid #eaeef5;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 500;
        /* This was 1rem, changed to 16px */
        color: #34495e;
        cursor: pointer;
        text-align: left;
        justify-content: space-between;
        align-items: center;
    }

    .ric-mobile-toggle[aria-expanded="true"] {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .ric-mobile-toggle[aria-expanded="true"]:hover,
    .ric-mobile-toggle[aria-expanded="true"]:focus {
        background-color: #f9fafc;
        outline: none;
    }

    .ric-collapsible-controls {
        display: block;
        max-height: 0;
        overflow: hidden;
        padding: 0 20px;
        background: #f9fafc;
        border: 1px solid #eaeef5;
        border-top: none;
        border-radius: 0 0 8px 8px;
        transition: max-height 0.4s ease-out, padding-top 0.4s ease-out, padding-bottom 0.4s ease-out;
    }

    .ric-collapsible-controls.open {
        max-height: 500px;
        /* Adjust if content is taller */
        padding-top: 20px;
    }

    .ric-action-buttons {
        justify-content: center;
    }

    .ric-crop-area {
        height: 300px;
    }

    .ric-selection-box {
        padding: 40px 0 40px 0;
    }

    .ric-action-buttons {
        margin-top: 20px;
    }

    select.ric-dimension-input {
        width: 100%;
    }
}