/**
 * ConvMaster - Image Crop Tool Styles
 * 
 * @package    ConvMaster
 * @version    1.0.2
 */

/* =====================================================
   HIDDEN ATTRIBUTE OVERRIDE
   display:flex/block overrides [hidden], fix it here
   ===================================================== */
[hidden].cropper__workspace,
[hidden].cropper__dropzone,
[hidden].cropper__error,
[hidden].cropper__option-group {
    display: none !important;
}

/* =====================================================
   TOOL PAGE LAYOUT
   ===================================================== */
.tool-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tool-header__icon {
    font-size: 2.5rem;
}

.tool-header__icon .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
}

.tool-header__text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--text-primary);
}

.tool-header__text p {
    margin: 0;
    color: var(--text-secondary);
}

/* =====================================================
   CROPPER WIDGET
   ===================================================== */
.cropper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* =====================================================
   DROP ZONE
   ===================================================== */
.cropper__dropzone {
    padding: 3rem 2rem;
    text-align: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    margin: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.cropper__dropzone:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.cropper__dropzone--active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.01);
}

.cropper__dropzone-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.cropper__dropzone-icon svg {
    width: 100%;
    height: 100%;
}

.cropper__dropzone-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.cropper__dropzone-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}

.cropper__dropzone-formats {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* =====================================================
   WORKSPACE
   ===================================================== */
.cropper__workspace {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* =====================================================
   INFO BAR
   ===================================================== */
.cropper__info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.cropper__source-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cropper__crop-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cropper__info-item {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.cropper__info-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.cropper__info-value {
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
}

/* =====================================================
   CANVAS AREA
   ===================================================== */
.cropper__canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 300px;
    max-height: 600px;
    overflow: hidden;
}

.cropper__canvas-container {
    position: relative;
    display: inline-block;
    line-height: 0;
    user-select: none;
    -webkit-user-select: none;
}

.cropper__canvas-container canvas {
    max-width: 100%;
    max-height: 560px;
    display: block;
    background-image:
        linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
        linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: 4px;
}

[data-theme="dark"] .cropper__canvas-container canvas {
    background-image:
        linear-gradient(45deg, #333 25%, transparent 25%),
        linear-gradient(-45deg, #333 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #333 75%),
        linear-gradient(-45deg, transparent 75%, #333 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* =====================================================
   CROP OVERLAY
   ===================================================== */
.cropper__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: crosshair;
}

.cropper__selection {
    position: absolute;
    border: 2px solid rgba(59, 130, 246, 0.9);
    background: transparent;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    cursor: move;
    min-width: 20px;
    min-height: 20px;
    z-index: 2;
}

.cropper__grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cropper__selection:hover .cropper__grid,
.cropper__selection:active .cropper__grid {
    opacity: 1;
}

.cropper__grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
}

.cropper__grid-line--h1 { top: 33.33%; left: 0; right: 0; height: 1px; }
.cropper__grid-line--h2 { top: 66.66%; left: 0; right: 0; height: 1px; }
.cropper__grid-line--v1 { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.cropper__grid-line--v2 { left: 66.66%; top: 0; bottom: 0; width: 1px; }

.cropper__handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 2px;
    z-index: 3;
}

.cropper__handle--nw { top: -7px; left: -7px; cursor: nw-resize; }
.cropper__handle--n  { top: -7px; left: 50%; margin-left: -7px; cursor: n-resize; }
.cropper__handle--ne { top: -7px; right: -7px; cursor: ne-resize; }
.cropper__handle--e  { top: 50%; right: -7px; margin-top: -7px; cursor: e-resize; }
.cropper__handle--se { bottom: -7px; right: -7px; cursor: se-resize; }
.cropper__handle--s  { bottom: -7px; left: 50%; margin-left: -7px; cursor: s-resize; }
.cropper__handle--sw { bottom: -7px; left: -7px; cursor: sw-resize; }
.cropper__handle--w  { top: 50%; left: -7px; margin-top: -7px; cursor: w-resize; }

.cropper__size-tag {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 4;
}

/* =====================================================
   OPTIONS
   ===================================================== */
.cropper__options {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cropper__option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cropper__option-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cropper__option-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 400;
}

.cropper__ratio-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cropper__ratio-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cropper__ratio-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cropper__ratio-btn--active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.cropper__format-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cropper__format-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cropper__format-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cropper__format-btn--active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.cropper__manual-inputs {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cropper__input-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cropper__input-field label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.cropper__input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    overflow: hidden;
}

.cropper__input-group input {
    width: 80px;
    padding: 0.4rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
}

.cropper__input-group input::placeholder {
    color: var(--text-muted);
}

.cropper__input-unit {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
}

.cropper__input-sep {
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0 0.25rem;
}

.cropper__slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.cropper__slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cropper__slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* =====================================================
   ACTIONS
   ===================================================== */
.cropper__actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.cropper__actions .btn {
    flex: 1;
    min-width: 120px;
}

.btn--small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* =====================================================
   ERROR BOX
   ===================================================== */
.cropper__error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #EF4444;
}

.cropper__error p {
    margin: 0;
    font-size: 0.9rem;
}

/* =====================================================
   PRIVACY NOTICE
   ===================================================== */
.cropper__privacy {
    text-align: center;
    padding: 0.5rem;
}

.cropper__privacy p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =====================================================
   ICON COLOR
   ===================================================== */
.icon--crop {
    background: rgba(245, 158, 11, 0.15);
}

/* =====================================================
   SEO CONTENT
   ===================================================== */
.tool-content {
    margin-top: 3rem;
}

.tool-section {
    margin-bottom: 3rem;
}

.tool-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem;
}

.tool-section p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.feature-card__icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Steps Grid */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
}

.step-card__number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 auto 1rem;
}

.step-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.step-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* FAQ List */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-item summary {
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item p {
    padding: 0 1.5rem 1rem;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* =====================================================
   BUTTONS (fallback if not in global CSS)
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn--primary {
    background: var(--primary);
    color: white;
}

.btn--primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn--secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn--secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn--success {
    background: #10B981;
    color: white;
}

.btn--success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 640px) {
    .tool-page {
        padding: 1rem;
    }
    
    .tool-header {
        flex-direction: column;
        text-align: center;
    }
    
    .cropper__dropzone {
        padding: 2rem 1rem;
        margin: 1rem;
    }
    
    .cropper__workspace {
        padding: 1rem;
    }
    
    .cropper__info-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .cropper__ratio-btns {
        gap: 0.35rem;
    }
    
    .cropper__ratio-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .cropper__manual-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cropper__input-sep {
        display: none;
    }
    
    .cropper__input-group input {
        width: 100%;
    }
    
    .cropper__actions {
        flex-direction: column;
    }
    
    .cropper__actions .btn {
        width: 100%;
    }
    
    .cropper__canvas-wrapper {
        min-height: 200px;
    }
    
    .cropper__handle {
        width: 18px;
        height: 18px;
    }
    
    .cropper__handle--nw { top: -9px; left: -9px; }
    .cropper__handle--n  { top: -9px; margin-left: -9px; }
    .cropper__handle--ne { top: -9px; right: -9px; }
    .cropper__handle--e  { right: -9px; margin-top: -9px; }
    .cropper__handle--se { bottom: -9px; right: -9px; }
    .cropper__handle--s  { bottom: -9px; margin-left: -9px; }
    .cropper__handle--sw { bottom: -9px; left: -9px; }
    .cropper__handle--w  { left: -9px; margin-top: -9px; }
}

@media (max-width: 480px) {
    .cropper__format-btns {
        flex-wrap: wrap;
    }
    
    .cropper__format-btn {
        flex: 1;
        min-width: 60px;
        text-align: center;
    }
}
