/*
 * QuickMonster Token Creator Component
 */

/* ========================================
   TOKEN CREATOR MODAL LAYOUT
   ======================================== */

.token-creator-modal {
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
}

.token-creator-body {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) 380px;
    gap: var(--qm-space-lg);
    padding: var(--qm-space-lg);
}

@media (max-width: 850px) {
    .token-creator-body {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   SOURCE CANVAS AREA
   ======================================== */

.token-source-area {
    display: flex;
    flex-direction: column;
    gap: var(--qm-space-md);
}

.token-source-container {
    position: relative;
    background: var(--qm-charcoal);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-md);
    overflow: hidden;
    aspect-ratio: 1;
    cursor: crosshair;
}

.token-source-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.token-source-hint {
    text-align: center;
    color: var(--qm-text-muted);
    font-size: var(--qm-text-sm);
}

/* ========================================
   PREVIEW AREA
   ======================================== */

.token-preview-area {
    display: flex;
    flex-direction: column;
    gap: var(--qm-space-md);
    min-height: 0;
}

.token-preview-area > .token-control-group:first-child {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
}

.token-preview-label {
    font-family: var(--qm-font-heading);
    color: var(--qm-gold);
    font-size: var(--qm-text-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.token-preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--qm-space-lg);
    background:
        linear-gradient(45deg, var(--qm-charcoal) 25%, transparent 25%),
        linear-gradient(-45deg, var(--qm-charcoal) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--qm-charcoal) 75%),
        linear-gradient(-45deg, transparent 75%, var(--qm-charcoal) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    background-color: var(--qm-obsidian);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-md);
    min-height: 280px;
    flex: 1;
}

.token-preview-canvas {
    max-width: 256px;
    max-height: 256px;
    width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ========================================
   CONTROL SECTIONS
   ======================================== */

.token-controls {
    display: flex;
    flex-direction: column;
    gap: var(--qm-space-sm);
    max-height: 320px;
    overflow-y: auto;
    padding-right: var(--qm-space-xs);
}

.token-controls::-webkit-scrollbar {
    width: 6px;
}

.token-controls::-webkit-scrollbar-track {
    background: var(--qm-charcoal);
    border-radius: 3px;
}

.token-controls::-webkit-scrollbar-thumb {
    background: var(--qm-granite);
    border-radius: 3px;
}

.token-controls::-webkit-scrollbar-thumb:hover {
    background: var(--qm-silver);
}

.token-control-group {
    display: flex;
    flex-direction: column;
    gap: var(--qm-space-xs);
}

.token-control-label {
    font-family: var(--qm-font-heading);
    color: var(--qm-gold);
    font-size: var(--qm-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   SHAPE SELECTOR
   ======================================== */

.token-shape-buttons {
    display: flex;
    gap: var(--qm-space-xs);
}

.token-shape-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--qm-space-sm);
    background: var(--qm-granite);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-text-muted);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
}

.token-shape-btn:hover {
    background: var(--qm-stone);
    border-color: var(--qm-silver);
    color: var(--qm-text-light);
}

.token-shape-btn.active {
    background: var(--qm-crimson-dark);
    border-color: var(--qm-gold);
    color: var(--qm-gold);
}

.token-shape-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.token-shape-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* ========================================
   BORDER COLOR SWATCHES
   ======================================== */

.token-color-swatches {
    display: flex;
    gap: var(--qm-space-xs);
    flex-wrap: wrap;
}

.token-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: var(--qm-radius-sm);
    border: 2px solid var(--qm-granite);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    position: relative;
}

.token-color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--qm-silver);
}

.token-color-swatch.active {
    border-color: var(--qm-text-light);
    box-shadow: 0 0 0 2px var(--qm-charcoal), 0 0 0 4px var(--qm-gold);
}

.token-color-swatch.no-border {
    background: repeating-linear-gradient(
        45deg,
        var(--qm-charcoal),
        var(--qm-charcoal) 4px,
        var(--qm-granite) 4px,
        var(--qm-granite) 8px
    );
}

.token-color-swatch.no-border::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--qm-coral);
    transform: rotate(-45deg);
}

/* ========================================
   BORDER STYLE BUTTONS
   ======================================== */

.token-style-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qm-space-xs);
}

.token-style-btn {
    flex: 1 1 calc(33% - var(--qm-space-xs));
    min-width: 60px;
    padding: var(--qm-space-xs) var(--qm-space-sm);
    background: var(--qm-granite);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-text-muted);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    font-size: var(--qm-text-xs);
    text-align: center;
}

.token-style-btn:hover {
    background: var(--qm-stone);
    border-color: var(--qm-silver);
    color: var(--qm-text-light);
}

.token-style-btn.active {
    background: var(--qm-crimson-dark);
    border-color: var(--qm-gold);
    color: var(--qm-gold);
}

/* ========================================
   EFFECT BUTTONS
   ======================================== */

.token-effect-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qm-space-xs);
}

.token-effect-btn {
    flex: 1 1 calc(25% - var(--qm-space-xs));
    min-width: 55px;
    padding: var(--qm-space-xs);
    background: var(--qm-granite);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-text-muted);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    font-size: var(--qm-text-xs);
    text-align: center;
}

.token-effect-btn:hover {
    background: var(--qm-stone);
    border-color: var(--qm-silver);
    color: var(--qm-text-light);
}

.token-effect-btn.active {
    background: var(--qm-crimson-dark);
    border-color: var(--qm-gold);
    color: var(--qm-gold);
}

/* ========================================
   TEXTURE BUTTONS
   ======================================== */

.token-texture-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qm-space-xs);
}

.token-texture-btn {
    flex: 1 1 calc(33% - var(--qm-space-xs));
    min-width: 55px;
    padding: var(--qm-space-xs);
    background: var(--qm-granite);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-text-muted);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    font-size: var(--qm-text-xs);
    text-align: center;
}

.token-texture-btn:hover {
    background: var(--qm-stone);
    border-color: var(--qm-silver);
    color: var(--qm-text-light);
}

.token-texture-btn.active {
    background: var(--qm-crimson-dark);
    border-color: var(--qm-gold);
    color: var(--qm-gold);
}

/* ========================================
   BORDER WIDTH SLIDER
   ======================================== */

.token-slider-container {
    display: flex;
    align-items: center;
    gap: var(--qm-space-sm);
}

.token-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--qm-granite);
    border-radius: 3px;
    outline: none;
}

.token-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--qm-gold);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--qm-transition-fast);
}

.token-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.token-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--qm-gold);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.token-slider-value {
    min-width: 36px;
    text-align: right;
    color: var(--qm-text-muted);
    font-size: var(--qm-text-sm);
}

/* ========================================
   SIZE SELECTOR
   ======================================== */

.token-size-buttons {
    display: flex;
    gap: var(--qm-space-xs);
}

.token-size-btn {
    flex: 1;
    padding: var(--qm-space-xs) var(--qm-space-sm);
    background: var(--qm-granite);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-text-muted);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    font-size: var(--qm-text-xs);
    text-align: center;
}

.token-size-btn:hover {
    background: var(--qm-stone);
    border-color: var(--qm-silver);
    color: var(--qm-text-light);
}

.token-size-btn.active {
    background: var(--qm-crimson-dark);
    border-color: var(--qm-gold);
    color: var(--qm-gold);
}

/* ========================================
   SAVE BUTTON
   ======================================== */

.token-save-section {
    margin-top: auto;
    padding-top: var(--qm-space-md);
    border-top: 1px solid var(--qm-granite);
}

.token-save-btn {
    width: 100%;
    padding: var(--qm-space-sm) var(--qm-space-md);
    background: linear-gradient(135deg, var(--qm-gold-dark) 0%, var(--qm-gold) 100%);
    border: none;
    border-radius: var(--qm-radius-sm);
    color: var(--qm-obsidian);
    font-family: var(--qm-font-heading);
    font-size: var(--qm-text-base);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
}

.token-save-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.token-save-btn:active {
    transform: translateY(0);
}

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

.token-save-btn.saving {
    position: relative;
    color: transparent;
}

.token-save-btn.saving::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--qm-obsidian);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   TOKEN GALLERY (in show.blade.php)
   ======================================== */

.token-gallery {
    margin-top: var(--qm-space-md);
}

.token-gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qm-space-sm);
}

.token-gallery-item {
    position: relative;
    width: 64px;
    height: 64px;
}

.token-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--qm-radius-sm);
    cursor: pointer;
    transition: transform var(--qm-transition-fast);
}

.token-gallery-item img:hover {
    transform: scale(1.1);
}

.token-gallery-item .token-delete-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--qm-coral);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--qm-transition-fast);
}

.token-gallery-item:hover .token-delete-btn {
    opacity: 1;
}

.token-gallery-item .token-delete-btn:hover {
    background: var(--qm-danger);
}

.token-gallery-empty {
    color: var(--qm-text-muted);
    font-size: var(--qm-text-sm);
    text-align: center;
    padding: var(--qm-space-md);
}

/* ========================================
   TOKEN LIGHTBOX
   ======================================== */

.token-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--qm-transition-normal), visibility var(--qm-transition-normal);
}

.token-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.token-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--qm-space-md);
}

.token-lightbox-image {
    max-width: 512px;
    max-height: 512px;
    width: auto;
    height: auto;
    border-radius: var(--qm-radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    /* Checkerboard background for transparency */
    background:
        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;
    background-color: #222;
}

.token-lightbox-close {
    position: absolute;
    top: -40px;
    right: -40px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--qm-granite);
    border: none;
    border-radius: 50%;
    color: var(--qm-text-light);
    font-size: 24px;
    cursor: pointer;
    transition: all var(--qm-transition-fast);
}

.token-lightbox-close:hover {
    background: var(--qm-coral);
    transform: scale(1.1);
}

.token-lightbox-actions {
    display: flex;
    gap: var(--qm-space-sm);
}

.token-lightbox-btn {
    padding: var(--qm-space-xs) var(--qm-space-md);
    background: var(--qm-granite);
    border: 1px solid var(--qm-silver);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-text-light);
    font-size: var(--qm-text-sm);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    text-decoration: none;
}

.token-lightbox-btn:hover {
    background: var(--qm-gold-dark);
    border-color: var(--qm-gold);
    color: var(--qm-gold);
}

/* ========================================
   CONFIRM DELETE MODAL
   ======================================== */

.confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--qm-transition-normal), visibility var(--qm-transition-normal);
}

.confirm-modal.active {
    opacity: 1;
    visibility: visible;
}

.confirm-modal-content {
    background: var(--qm-charcoal);
    border: 2px solid var(--qm-granite);
    border-radius: var(--qm-radius-md);
    padding: var(--qm-space-lg);
    max-width: 360px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.confirm-modal-icon {
    font-size: 3rem;
    margin-bottom: var(--qm-space-sm);
}

.confirm-modal-title {
    font-family: var(--qm-font-heading);
    color: var(--qm-gold);
    font-size: var(--qm-text-lg);
    margin-bottom: var(--qm-space-xs);
}

.confirm-modal-message {
    color: var(--qm-text-muted);
    font-size: var(--qm-text-sm);
    margin-bottom: var(--qm-space-lg);
}

.confirm-modal-actions {
    display: flex;
    gap: var(--qm-space-sm);
    justify-content: center;
}

.confirm-modal-btn {
    padding: var(--qm-space-sm) var(--qm-space-lg);
    border: none;
    border-radius: var(--qm-radius-sm);
    font-family: var(--qm-font-heading);
    font-size: var(--qm-text-sm);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
}

.confirm-modal-btn-cancel {
    background: var(--qm-granite);
    color: var(--qm-text-light);
}

.confirm-modal-btn-cancel:hover {
    background: var(--qm-stone);
}

.confirm-modal-btn-delete {
    background: var(--qm-coral);
    color: white;
}

.confirm-modal-btn-delete:hover {
    background: var(--qm-danger);
}

/* ========================================
   IMAGE SECTION TABS
   ======================================== */

.image-section-tabs {
    display: flex;
    border-bottom: 2px solid var(--qm-granite);
    margin-bottom: var(--qm-space-md);
}

.image-section-tab {
    flex: 1;
    padding: var(--qm-space-sm) var(--qm-space-md);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--qm-text-muted);
    font-family: var(--qm-font-heading);
    font-size: var(--qm-text-sm);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--qm-space-xs);
}

.image-section-tab:hover {
    color: var(--qm-text-light);
    background: rgba(255, 255, 255, 0.05);
}

.image-section-tab.active {
    color: var(--qm-gold);
    border-bottom-color: var(--qm-gold);
}

.image-section-tab-icon {
    font-size: 1.1rem;
}

.image-section-content {
    display: none;
}

.image-section-content.active {
    display: block;
}

/* ========================================
   CREATE TOKEN BUTTON
   ======================================== */

.create-token-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--qm-space-xs);
    width: 100%;
    padding: var(--qm-space-sm) var(--qm-space-md);
    background: linear-gradient(135deg, var(--qm-midnight-blue) 0%, var(--qm-charcoal) 100%);
    border: 2px solid var(--qm-gold-dark);
    border-radius: var(--qm-radius-sm);
    color: var(--qm-gold);
    font-family: var(--qm-font-heading);
    font-size: var(--qm-text-sm);
    cursor: pointer;
    transition: all var(--qm-transition-fast);
}

.create-token-btn:hover {
    border-color: var(--qm-gold);
    background: linear-gradient(135deg, var(--qm-void-purple) 0%, var(--qm-midnight-blue) 100%);
}

.create-token-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
