/* ==========================================================================
   Instagram Profile Picture Maker — Modular Responsive Design System
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --ig-brand: #e1306c;
    --ig-brand-hover: #c13584;
    --ig-gradient: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    --ig-success: #059669;
    --ig-success-hover: #047857;
    --ig-dark: #0f172a;
}

.ig-container {
    width: 100%;
    max-width: 960px;
    margin-inline: auto;
    padding-inline: clamp(12px, 3vw, 24px);
    box-sizing: border-box;
}

/* ──── Multi-Device Workspace Grid Breakpoints ──── */
.ig-workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ig-workspace-grid > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Defensive CLS=0 Canvas Stage Container */
.ig-canvas-stage {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 420px;
    aspect-ratio: 1 / 1;
    background: #0f172a;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.4);
    user-select: none;
    touch-action: none;
    box-sizing: border-box;
}

.ig-canvas-stage canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: grab;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.ig-canvas-stage canvas:active {
    cursor: grabbing;
}

/* Small Desktop / Landscape Tablet (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .ig-workspace-grid {
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: 20px;
    }
}

/* Tablet / iPad Layout (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .ig-workspace-grid {
        grid-template-columns: minmax(0, 1fr) 290px;
        gap: 16px;
    }
    .ig-canvas-stage {
        height: 360px;
    }
    .ig-controls-card,
    .ig-action-card {
        padding: 18px 14px;
    }
}

/* Mobile Phones (320px - 767px) */
@media (max-width: 767px) {
    .ig-container {
        padding-inline: 12px;
    }
    .ig-workspace-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
    .ig-canvas-stage {
        height: 290px;
        max-height: 45vh;
    }
    .ig-controls-card,
    .ig-action-card {
        padding: 16px 12px;
    }
    .btn-download-primary,
    .btn-download-zip {
        font-size: 14px !important;
        padding: 12px 14px !important;
    }
}

/* Extra Small Mobile (< 360px) */
@media (max-width: 359px) {
    .ig-container {
        padding-inline: 8px;
    }
    .ig-canvas-stage {
        height: 240px;
    }
}

/* Controls Panel & Cards */
.ig-controls-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 100%;
    box-shadow: 0 4px 20px rgba(15, 45, 89, 0.03);
    box-sizing: border-box;
    overflow: hidden;
}

.control-group {
    margin-bottom: 18px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.control-group label {
    display: block;
    font-size: 13.5px;
    font-weight: 700;
    color: #0f2d59;
    margin-bottom: 8px;
}

/* Profile Ring Chips Toolbar */
.ring-presets-wrapper {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.ring-chip {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 6px 14px;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
}

.ring-chip.active {
    background: var(--ig-brand);
    border-color: var(--ig-brand);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 48, 108, 0.25);
}

/* Shape Tabs */
.shape-tabs {
    display: flex;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.shape-tab {
    flex: 1;
    min-height: 42px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.shape-tab.active {
    background: var(--ig-brand);
    border-color: var(--ig-brand);
    color: #ffffff;
}

/* Touch Range Sliders */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    max-width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    outline: none;
    margin: 8px 0;
    touch-action: none;
    box-sizing: border-box;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ig-brand);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(225, 48, 108, 0.4);
    border: 2.5px solid #ffffff;
}

/* Action & Download Card */
.ig-action-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 100%;
    margin-top: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(15, 45, 89, 0.03);
    box-sizing: border-box;
    overflow: hidden;
}

.btn-download-primary,
.btn-download-zip {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    height: auto !important;
    padding: 12px 16px !important;
    background-color: var(--ig-brand) !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    border: none !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    opacity: 1 !important;
    visibility: visible !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    text-align: center !important;
    box-shadow: 0 4px 14px rgba(225, 48, 108, 0.3) !important;
}

.btn-download-zip {
    background-color: var(--ig-success) !important;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25) !important;
    margin-top: 10px !important;
}

.btn-download-primary svg,
.btn-download-zip svg {
    flex-shrink: 0 !important;
    color: #ffffff !important;
    stroke: #ffffff !important;
    fill: none !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 18px !important;
    height: 18px !important;
}

.btn-download-primary span,
.btn-download-primary .btn-text,
.btn-download-zip span,
.btn-download-zip .btn-text {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
    line-height: 1.3 !important;
    text-indent: 0 !important;
}

.spinner-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
