/* ============================================================
 * AHR Grid Maker - CSS Styles
 * ============================================================
 * All the styling for the grid maker tool.
 */

/* Main Container */
.ahr-grid-container {
    display: flex;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Left Sidebar */
.ahr-grid-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Section */
.ahr-grid-section {
    background: white;
    border: 1px solid #d6d9dd;
    border-radius: 8px;
    overflow: hidden;
}

.ahr-grid-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #596065;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ahr-grid-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ahr-grid-section-icon {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
    opacity: 1;
    fill: white;
    color: white;
}

.ahr-grid-section-title h2 {
    font-size: 15.6px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.78px;
    margin: 0;
}

.ahr-grid-settings-icon {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
    opacity: 0.8;
    fill: white;
    color: white;
}

.ahr-grid-section-icon path,
.ahr-grid-section-icon circle {
    fill: white;
}

.ahr-grid-settings-icon path {
    fill: white;
}

.ahr-grid-section-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Brightness & contrast: hidden until an image is loaded (JS toggles visibility) */
.ahr-grid-brightness-contrast-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Toggle Switch */
.ahr-grid-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    flex-shrink: 0;
}

.ahr-grid-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ahr-grid-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 20px;
}

.ahr-grid-toggle-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.ahr-grid-toggle input:checked + .ahr-grid-toggle-slider {
    background-color: #2ba1e9;
}

.ahr-grid-toggle input:checked + .ahr-grid-toggle-slider::before {
    transform: translateX(20px);
}

/* Upload Button */
.ahr-grid-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: #e0e5e7;
    border-radius: 6px;
    color: #5e6163;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.ahr-grid-upload-btn:hover {
    background: #d4d9db;
    color: #4a4d4f;
    transform: translateY(-1px);
    box-shadow: none;
}

.ahr-grid-upload-icon {
    width: 19.2px;
    height: 19.2px;
    opacity: 0.5;
    margin-top: 2px;
}

/* Setting Row */
.ahr-grid-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #4b5563;
}

.ahr-grid-setting-row > span:first-child {
    width: 112px;
    min-width: 112px;
    flex-shrink: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ahr-grid-info-icon-wrapper {
    display: inline-block;
    position: relative;
    vertical-align: middle;
    margin-left: 1.6px;
    width: 12.8px;
    height: 12.8px;
    line-height: 0;
    flex-shrink: 0;
}

.ahr-grid-info-icon {
    width: 12px;
    height: 12px;
    opacity: 0.3;
    display: block;
    flex-shrink: 0;
    object-fit: contain;
}

/* Tooltip bubble styling */
.ahr-grid-tooltip {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    padding: 6px 10px;
    background: #0f172a;
    color: #ffffff;
    font-size: 11.2px;
    font-weight: 400;
    white-space: normal;
    max-width: 200px !important;
    width: max-content;
    min-width: 100px;
    word-wrap: break-word;
    border-radius: 4px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    line-height: 1.4;
}

/* Arrow pointing up to icon */
.ahr-grid-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 4px solid #0f172a;
}

/* Show tooltip on hover */
.ahr-grid-info-icon-wrapper:hover .ahr-grid-tooltip {
    opacity: 1;
    visibility: visible;
}

.ahr-grid-subtext {
    font-size: 12px;
    color: #9ca3af;
}

/* Number Input Group */
.ahr-grid-number-input-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #4b5563;
}

.ahr-grid-number-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ahr-grid-number-btn {
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 0;
    font-size: 0;
    font-weight: normal;
    color: transparent;
    cursor: pointer;
    transition: none;
    padding: 0;
    margin: 0;
    outline: none;
    box-shadow: none;
}

.ahr-grid-number-btn:hover,
.ahr-grid-number-btn:focus,
.ahr-grid-number-btn:active {
    background: none;
    border: none;
    outline: none;
    box-shadow: none;
    transform: none;
}

.ahr-grid-btn-icon {
    width: 20px;
    height: 20px;
    opacity: 1;
    display: block;
    filter: brightness(0) saturate(100%) invert(68%) sepia(5%) saturate(600%) hue-rotate(200deg) brightness(98%) contrast(92%);
}

.ahr-grid-number-input-group input[type="number"] {
    width: 35.2px;
    padding: 6.8px 2.4px !important;
    border: 1px solid #d6d9dd;
    border-radius: 20px;
    background-color: #f7f7f7;
    font-size: 15.2px;
    font-weight: 700;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
    pointer-events: none;
    user-select: none;
    line-height: 1.2;
    min-height: auto;
    height: auto;
    box-sizing: border-box;
}

.ahr-grid-number-input-group input[type="number"]::-webkit-inner-spin-button,
.ahr-grid-number-input-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.ahr-grid-custom-size {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Color Picker - circular swatch */
.ahr-grid-color-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.ahr-grid-color-picker > span {
    font-size: 12px;
    color: #9ca3af;
}

.ahr-grid-color-picker input[type="color"] {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    background: transparent;
    box-shadow:
        0 0 0 2px #fff,
        0 0 0 3px #d6d9dd,
        0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
}

.ahr-grid-color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.ahr-grid-color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.ahr-grid-color-picker input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

.ahr-grid-color-picker input[type="color"]:focus {
    outline: none;
    box-shadow:
        0 0 0 2px #fff,
        0 0 0 4px #2ba1e9,
        0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Slider Group */
.ahr-grid-slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ahr-grid-value-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
}

/* Line opacity & line width: match brightness/contrast slider look (value same as .ahr-grid-slider-value) */
.ahr-grid-slider-group .ahr-grid-value-badge {
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: #6b7280;
    width: 40px;
    min-width: 40px;
    text-align: right;
}

.ahr-grid-slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 9999px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
    transition: none;
    box-sizing: border-box;
}

.ahr-grid-slider-group input[type="range"]:hover,
.ahr-grid-slider-group input[type="range"]:active,
.ahr-grid-slider-group input[type="range"]:focus {
    background: #e5e7eb;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #9ca3af;
    cursor: pointer;
    margin-top: 0.7px !important;
    transition: none;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.ahr-grid-slider-group input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #9ca3af;
    cursor: pointer;
    border: none;
    transition: none;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-slider-group input[type="range"]:hover::-webkit-slider-thumb,
.ahr-grid-slider-group input[type="range"]:active::-webkit-slider-thumb,
.ahr-grid-slider-group input[type="range"]:focus::-webkit-slider-thumb {
    background: #2ba1e9;
}

.ahr-grid-slider-group input[type="range"]:hover::-moz-range-thumb,
.ahr-grid-slider-group input[type="range"]:active::-moz-range-thumb,
.ahr-grid-slider-group input[type="range"]:focus::-moz-range-thumb {
    background: #2ba1e9;
}

/* Slider Wrapper (for brightness/contrast) */
.ahr-grid-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    width: auto;
    min-width: 0;
    margin-left: 8px;
    flex-shrink: 1;
    flex: 1;
    justify-content: flex-end;
}

.ahr-grid-slider-reset-container {
    width: 10.4px;
    height: 10.4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ahr-grid-slider {
    width: auto;
    min-width: 130px;
    flex: 0 1 auto;
    max-width: 200px;
    height: 6px;
    border-radius: 9999px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    margin: 0;
    padding: 0;
    transition: none;
    box-sizing: border-box;
}

.ahr-grid-slider:hover,
.ahr-grid-slider:active,
.ahr-grid-slider:focus {
    background: #e5e7eb;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #9ca3af;
    cursor: pointer;
    margin-top: 0.7px !important;
    transition: none;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.ahr-grid-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #9ca3af;
    cursor: pointer;
    border: none;
    transition: none;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-slider.active::-webkit-slider-thumb {
    background: #2ba1e9;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.ahr-grid-slider.active::-moz-range-thumb {
    background: #2ba1e9;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.ahr-grid-slider-value {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    width: 40px;
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.ahr-grid-slider-reset {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 9.6px;
    height: 9.6px;
    opacity: 0.5;
    transition: none;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-slider-reset:hover,
.ahr-grid-slider-reset:active,
.ahr-grid-slider-reset:focus,
.ahr-grid-slider-reset:focus-visible {
    opacity: 0.5 !important;
    outline: none !important;
    box-shadow: none !important;
    background: none !important;
    border: none !important;
    background-color: transparent !important;
}

.ahr-grid-slider-reset svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    color: #6b7280;
}

/* Canvas Wrapper */
.ahr-grid-canvas-wrapper {
    flex: 1;
    position: relative;
    background: #d4d9db;
    border: 1px solid #b9bdc4;
    border-radius: 8px;
    height: 655px;
    min-height: 655px;
    max-height: 655px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#grid-canvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

/* Zoom Overlay */
.ahr-grid-zoom-overlay {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 24px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.ahr-grid-zoom-overlay.show {
    opacity: 1;
}

.ahr-grid-zoom-overlay-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ahr-grid-zoom-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Empty State */
.ahr-grid-empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.ahr-grid-empty-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.ahr-grid-empty-btn,
#empty-upload-btn {
    background: transparent !important;
    border: none !important;
    padding: 0;
    cursor: pointer;
    outline: none !important;
    transition: transform 0.15s;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.ahr-grid-empty-btn:hover,
.ahr-grid-empty-btn:focus,
.ahr-grid-empty-btn:focus-visible,
.ahr-grid-empty-btn:active,
#empty-upload-btn:hover,
#empty-upload-btn:focus,
#empty-upload-btn:focus-visible,
#empty-upload-btn:active {
    transform: scale(1.05);
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.ahr-grid-empty-btn::-moz-focus-inner,
#empty-upload-btn::-moz-focus-inner {
    border: 0 !important;
    outline: none !important;
    padding: 0 !important;
}

.ahr-grid-empty-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-empty-btn::before,
.ahr-grid-empty-btn::after,
#empty-upload-btn::before,
#empty-upload-btn::after,
.ahr-grid-empty-btn-icon::before,
.ahr-grid-empty-btn-icon::after {
    display: none !important;
    content: none !important;
    background: none !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.ahr-grid-empty-btn-icon .ahr-grid-add-icon {
    width: 128px !important;
    height: 128px !important;
    max-width: 128px !important;
    max-height: 128px !important;
    min-width: 128px !important;
    min-height: 128px !important;
    display: block !important;
    opacity: 0.5;
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    backface-visibility: hidden;
    transform: translateZ(0);
    object-fit: contain;
}

.ahr-grid-empty-btn-icon .ahr-grid-add-icon path {
    fill: #000000;
}

.ahr-grid-empty-content p {
    color: #5b5f61;
    font-size: 12.8px;
    margin: 0;
    line-height: 1.3;
}

/* Download Button */
.ahr-grid-download-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: none !important;
    visibility: hidden;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #2ba1e9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    z-index: 10;
    transition: background 0.15s;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    white-space: nowrap;
}

.ahr-grid-download-btn[style*="display: block"] {
    display: flex !important;
    visibility: visible !important;
}

.ahr-grid-download-btn:hover {
    background: #1a8fd8;
}

.ahr-grid-download-btn > * {
    display: inline-block;
    vertical-align: middle;
}

.ahr-grid-download-icon {
    width: 16px;
    height: 16px;
    display: inline-block !important;
    flex-shrink: 0;
    vertical-align: middle;
}

.ahr-grid-download-icon path {
    fill: currentColor;
}

.ahr-grid-download-btn span {
    display: inline-block !important;
    vertical-align: middle;
    white-space: nowrap;
}
