/* ============================================================================
   IMAGE COMPARISON TOOL - Page Styles
   ============================================================================

   Interactive side-by-side image comparison tool with draggable slider.

   Features:
   - Collapsible controls panel for image upload/URL input
   - Draggable comparison slider (mouse & touch support)
   - Image labels overlay
   - Responsive layout for mobile
   - Toast notifications for user feedback

   Most styles scoped to 'main' to prevent affecting header/footer.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Main Layout
   ---------------------------------------------------------------------------- */

main {
    padding: 20px;
    /* Ensure long words and URLs wrap properly */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

main .container {
    max-width: 1200px;
    margin: 0 auto;
}

main header {
    margin-bottom: 30px;
}

main h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--color-nav-bg);  /* #2c3e50 from common.css */
}

main .subtitle {
    color: #666;
    font-size: 0.95rem;
}

/* ----------------------------------------------------------------------------
   Controls Panel - Collapsible upload/URL input section
   ---------------------------------------------------------------------------- */

.controls {
    background: #fff;
    border: 1px solid var(--color-border);  /* #ddd from common.css */
    border-radius: var(--radius-md);        /* 8px from common.css */
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Controls header - clickable to expand/collapse */
.controls-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--color-border);
}

.controls-header:hover {
    background: #f9f9f9;
}

.controls-title {
    font-weight: 600;
    font-size: var(--font-size-base);    /* 16px from common.css */
    color: var(--color-nav-bg);          /* #2c3e50 from common.css */
}

/* Chevron icon that rotates when collapsed */
.controls-toggle {
    font-size: 1.2rem;
    color: #666;
    transition: transform var(--transition-medium);  /* 0.3s from common.css */
}

.controls.collapsed .controls-toggle {
    transform: rotate(-90deg);
}

/* Controls body - contains form inputs */
.controls-body {
    padding: 20px;
}

.controls.collapsed .controls-body {
    display: none;
}

/* Image configuration sections */
.image-config-section {
    margin-bottom: 24px;
}

.image-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-nav-bg);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
}

/* Divider between left and right image configs */
.config-divider {
    height: 1px;
    background: var(--color-border);
    margin: 24px 0;
}

.control-group {
    margin-bottom: 16px;
}

.control-group:last-child {
    margin-bottom: 0;
}

/* ----------------------------------------------------------------------------
   Form Elements - Inputs and Buttons
   ---------------------------------------------------------------------------- */

main label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text-secondary);  /* #555 from common.css */
    font-size: 0.9rem;
    font-weight: 500;
}

main input[type="text"],
main input[type="file"] {
    width: 100%;
    padding: 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: var(--radius-sm);      /* 4px from common.css */
    color: var(--color-text-primary);     /* #333 from common.css */
    font-size: 0.95rem;
    box-sizing: border-box;               /* Include padding/border in width */
}

main input[type="text"]:focus,
main input[type="file"]:focus {
    outline: none;
    border-color: var(--color-primary);   /* #007acc from common.css */
}

main input[type="file"] {
    padding: 8px;
}

main .button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* Primary buttons */
main button {
    padding: 10px 20px;
    background: var(--color-primary);              /* #007acc from common.css */
    border: none;
    border-radius: var(--radius-sm);               /* 4px from common.css */
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition-fast); /* 0.2s from common.css */
}

main button:hover {
    background: var(--color-primary-hover);        /* #005a99 from common.css */
}

main button:active {
    background: var(--color-primary-active);       /* #004578 from common.css */
}

/* Secondary buttons (e.g., "Clear") */
main button.secondary {
    background: #f0f0f0;
    border: 1px solid #ccc;
    color: var(--color-text-primary);
}

main button.secondary:hover {
    background: #e0e0e0;
}

/* ----------------------------------------------------------------------------
   Comparison Container - Main image comparison area
   ---------------------------------------------------------------------------- */

.comparison-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;  /* Prevent text selection during drag */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Wrapper maintains 16:9 aspect ratio */
.comparison-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio (9/16 = 0.5625) */
    background: #f9f9f9;
}

.comparison-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ----------------------------------------------------------------------------
   Image Layers - Left and right images with clipping
   ---------------------------------------------------------------------------- */

.image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;  /* Maintain aspect ratio */
    display: block;
}

/* Left image - shown in full */
.image-left {
    z-index: 1;
}

/* Right image - clipped to show only right half (adjusted by slider) */
.image-right {
    z-index: 2;
    clip-path: inset(0 0 0 50%);  /* Clip from left at 50% (adjusted via JS) */
}

/* ----------------------------------------------------------------------------
   Comparison Slider - Draggable divider between images
   ---------------------------------------------------------------------------- */

.slider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: var(--color-primary);  /* #007acc from common.css */
    cursor: ew-resize;                 /* East-west resize cursor */
    z-index: 3;
    transform: translateX(-50%);
}

/* Slider handle - circular button in center */
.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 3px solid var(--color-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Arrow indicators on handle (left and right triangles) */
.slider-handle::before,
.slider-handle::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* Left arrow */
.slider-handle::before {
    left: 8px;
    border-width: 6px 8px 6px 0;
    border-color: transparent var(--color-primary) transparent transparent;
}

/* Right arrow */
.slider-handle::after {
    right: 8px;
    border-width: 6px 0 6px 8px;
    border-color: transparent transparent transparent var(--color-primary);
}

/* ----------------------------------------------------------------------------
   Image Labels - Overlay labels for left/right images
   ---------------------------------------------------------------------------- */

.label {
    position: absolute;
    top: 20px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    z-index: 4;
    backdrop-filter: blur(4px);
    border: 1px solid var(--color-border);
}

.label-left {
    left: 20px;
}

.label-right {
    right: 20px;
}

/* ----------------------------------------------------------------------------
   Placeholder Text - Shown when no images loaded
   ---------------------------------------------------------------------------- */

.placeholder {
    color: #999;
    text-align: center;
    padding: 40px;
}

/* ----------------------------------------------------------------------------
   Toast Notifications - Temporary feedback messages
   ---------------------------------------------------------------------------- */

.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: var(--z-index-hamburger);  /* Same as hamburger (1000) */
    opacity: 0;
    transition: opacity var(--transition-medium);
}

.notification.show {
    opacity: 1;
}

/* ----------------------------------------------------------------------------
   Responsive Styles - Mobile Optimizations
   ---------------------------------------------------------------------------- */

@media (max-width: 768px) {
    /* Smaller heading on mobile */
    main h1 {
        font-size: 1.5rem;
    }

    /* Less padding on controls */
    .controls {
        padding: 15px;
    }

    /* Stack buttons vertically on mobile */
    main .button-group {
        flex-direction: column;
    }

    main button {
        width: 100%;  /* Full width buttons for easier tapping */
    }

    /* Smaller labels on mobile */
    .label {
        font-size: 0.8rem;
        padding: 6px 12px;
        top: 10px;
    }

    .label-left {
        left: 10px;
    }

    .label-right {
        right: 10px;
    }
}
