/* Mixtiles Planner - App-specific styles */
/* Inherits base theming from ../../styles.css */

/* Mixtiles-specific color extensions */
:root {
    --panel-background: #f0f0f5;
    --tile-gradient-start: #9a8abf;
    --tile-gradient-end: #7a6a9f;
    --stat-accent: var(--accent-color);
    --border-subtle: #ddd;
}

.dark-mode {
    --panel-background: #242442;
    --tile-gradient-start: #4a4a6a;
    --tile-gradient-end: #3a3a5a;
    --border-subtle: #3a3a5a;
}

/* Page Layout */
.mixtiles-page {
    padding: 20px;
    padding-top: 80px; /* Account for fixed header */
    min-height: 100vh;
}

.mixtiles-page h1 {
    text-align: center;
    margin: 0 0 5px 0;
    font-size: 24px;
}

.subtitle {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 14px;
}

.container {
    display: flex;
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
    justify-content: center;
}

/* Panels */
.panel {
    background: var(--panel-background);
    border-radius: 12px;
    padding: 20px;
}

.panel h2 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-color);
}

/* Wall Area */
.wall-panel {
    flex: 0 0 auto;
}

.wall-container {
    position: relative;
}

.wall {
    width: 450px;  /* 60" at 7.5px per inch */
    height: 405px; /* 54" at 7.5px per inch */
    background: linear-gradient(135deg, #f5f5f0 0%, #e8e8e0 100%);
    border-radius: 4px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.wall-dimensions {
    position: absolute;
    color: var(--text-color);
    font-size: 11px;
}

.wall-width {
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
}

.wall-height {
    right: -35px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

/* Tiles */
.tile {
    position: absolute;
    background: linear-gradient(145deg, var(--tile-gradient-start), var(--tile-gradient-end));
    border-radius: 4px;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s;
    overflow: hidden;
    user-select: none;
}

.tile:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.tile.dragging {
    opacity: 0.8;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.tile.selected {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.tile-label {
    background: rgba(0, 0, 0, 0.6);
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 10px;
    pointer-events: none;
}

.tile .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(200, 80, 80, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tile:hover .delete-btn {
    display: flex;
}

/* Tile Palette */
.palette-panel {
    width: 280px;
}

.palette {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--background-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.palette-item:hover {
    background: var(--card-background);
}

.palette-preview {
    background: linear-gradient(145deg, var(--tile-gradient-start), var(--tile-gradient-end));
    border-radius: 3px;
    flex-shrink: 0;
}

.palette-info {
    flex: 1;
}

.palette-size {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.palette-dims {
    font-size: 11px;
    color: var(--text-color);
}

.palette-add {
    background: var(--accent-color);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.palette-add:hover {
    opacity: 0.85;
}

/* Stats & Controls */
.stats-panel {
    width: 280px;
}

.stats {
    background: var(--background-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stat-row:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: var(--text-color);
}

.stat-value {
    font-weight: 600;
    color: var(--accent-color);
}

.inventory {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-subtle);
}

.inventory-title {
    font-size: 12px;
    color: var(--text-color);
    margin-bottom: 10px;
}

.inventory-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.inventory-item {
    background: var(--panel-background);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--primary-color);
}

.inventory-item .count {
    color: var(--accent-color);
    font-weight: bold;
}

/* Buttons */
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s;
}

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

.btn-primary:hover {
    opacity: 0.85;
}

.btn-danger {
    background: #c44;
    color: white;
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-secondary {
    background: var(--border-subtle);
    color: var(--primary-color);
}

.btn-secondary:hover {
    opacity: 0.85;
}

/* Instructions */
.instructions {
    margin-top: 15px;
    padding: 15px;
    background: var(--background-color);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-color);
    line-height: 1.6;
}

.instructions strong {
    color: var(--primary-color);
}

/* Grid Overlay */
.wall-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.15) 1px, transparent 1px);
    background-size: 3.75px 3.75px; /* 0.5" * 7.5 scale */
}

.dark-mode .wall-grid {
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
}

/* Rotate Button */
.tile .rotate-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: rgba(80, 100, 200, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.tile:hover .rotate-btn {
    display: flex;
}

.tile .rotate-btn:hover {
    background: rgba(60, 80, 180, 1);
}

/* Invalid Position State */
.tile.invalid-position {
    background: rgba(204, 68, 68, 0.7) !important;
    box-shadow: 0 5px 20px rgba(204, 68, 68, 0.5);
}

/* Settings Groups */
.settings-group {
    margin-bottom: 15px;
    padding: 12px;
    background: var(--background-color);
    border-radius: 8px;
}

.settings-group h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 10px 0;
    color: var(--primary-color);
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    font-size: 13px;
    color: var(--text-color);
}

.setting-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.setting-row input[type="number"] {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-size: 13px;
    background: var(--panel-background);
    color: var(--primary-color);
}

.setting-row .unit {
    font-size: 12px;
    color: var(--text-color);
}

/* Controls Grid for Save/Load */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Tile Set Selector */
.set-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    align-items: center;
}

.set-selector select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 13px;
    background: var(--background-color);
    color: var(--primary-color);
    cursor: pointer;
}

/* Button Variants */
.btn-small {
    padding: 8px 14px;
    font-size: 12px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 16px;
    background: var(--border-subtle);
    color: var(--primary-color);
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 0.8;
}

.btn-full {
    width: 100%;
}

.btn-tiny {
    width: 22px;
    height: 22px;
    font-size: 12px;
    border-radius: 4px;
}

.btn-danger-tiny {
    background: rgba(200, 80, 80, 0.8);
    color: white;
}

/* Palette Edit Buttons */
.palette-edit-buttons {
    display: flex;
    gap: 4px;
}

.palette-add-tile {
    margin-top: 10px;
}

/* Price Display */
.palette-price {
    font-size: 11px;
    color: var(--accent-color);
    font-weight: 400;
    margin-left: 4px;
}

.subtotal {
    font-size: 10px;
    color: var(--accent-color);
    margin-left: 4px;
}

#total-cost {
    font-size: 16px;
}

.no-tiles {
    color: var(--text-color);
    font-size: 12px;
}

/* Modal System */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--panel-background);
    padding: 24px;
    border-radius: 12px;
    min-width: 320px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin: 0 0 16px 0;
    color: var(--primary-color);
    font-size: 18px;
}

.modal-content input[type="text"],
.modal-content input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 12px;
    background: var(--background-color);
    color: var(--primary-color);
    font-size: 14px;
}

.modal-content input::placeholder {
    color: var(--text-color);
    opacity: 0.7;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Form Groups */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-color);
    margin-bottom: 4px;
}

.form-group small {
    display: block;
    font-size: 11px;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: 4px;
}

/* Layout List */
.layouts-list {
    max-height: 300px;
    overflow-y: auto;
}

.layout-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--background-color);
    border-radius: 8px;
    margin-bottom: 8px;
}

.layout-item:last-child {
    margin-bottom: 0;
}

.layout-item-info {
    flex: 1;
    min-width: 0;
}

.layout-item-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layout-item-meta {
    font-size: 11px;
    color: var(--text-color);
}

.layout-item-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

.no-layouts {
    color: var(--text-color);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .mixtiles-page {
        padding: 10px;
        padding-top: 70px;
    }

    .container {
        gap: 15px;
    }

    .palette-panel,
    .stats-panel {
        width: 100%;
    }

    .wall {
        max-width: 100%;
        height: auto;
        aspect-ratio: 60 / 54;
    }

    .modal-content {
        min-width: auto;
        margin: 20px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }
}

/* Help Button */
.wall-panel {
    position: relative;
}

.btn-help {
    position: absolute;
    top: 21px;
    right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
    z-index: 10;
}

.btn-help:hover {
    opacity: 0.8;
}

/* Help Modal Specific Styles */
.help-modal-content {
    max-width: 500px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--border-subtle);
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 0.7;
}

.help-section {
    margin-bottom: 20px;
}

.help-section:last-of-type {
    margin-bottom: 0;
}

.help-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 8px 0;
}

.help-section p {
    font-size: 13px;
    color: var(--text-color);
    line-height: 1.5;
    margin: 0;
}

.help-section p + p {
    margin-top: 10px;
}

.help-section a {
    color: var(--accent-color);
}

.help-section ul,
.help-section ol {
    font-size: 13px;
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 6px;
}

.help-section li:last-child {
    margin-bottom: 0;
}

.help-section strong {
    color: var(--primary-color);
}
