/**
 * RoK Tactical Map Planner - Main Stylesheet
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4287f5;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --bg-dark: #1a1a2e;
    --bg-light: #f8f9fa;
    --text-dark: #333;
    --text-light: #fff;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-dark);
}

/* Container & Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 2rem;
}

.maps-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.maps-card h2 {
    margin-bottom: 1.5rem;
    color: var(--bg-dark);
}

.maps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.map-thumbnail {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.map-thumbnail:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.map-thumbnail img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.map-name {
    padding: 0.75rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.map-thumbnail .btn-small {
    width: 100%;
    border-radius: 0;
    margin: 0;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.no-maps {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem;
}

@media (max-width: 768px) {
    .maps-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
}

.upload-card, .info-card, .install-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.upload-card h2, .info-card h3, .install-card h3 {
    margin-bottom: 1.5rem;
    color: var(--bg-dark);
}

.install-card {
    margin-top: 2rem;
}

.install-card p {
    margin-bottom: 1.5rem;
    color: var(--text-dark);
}

.install-instructions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.install-item {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.install-item strong {
    display: block;
    margin-bottom: 1rem;
    color: var(--bg-dark);
    font-size: 1.1rem;
}

.install-item ol {
    margin: 0;
    padding-left: 1.5rem;
}

.install-item li {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    line-height: 1.6;
}

@media (max-width: 768px) {
    .install-instructions {
        grid-template-columns: 1fr;
    }
}

/* File Input */
.file-input-wrapper {
    margin-bottom: 1.5rem;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

.file-label {
    display: block;
    padding: 2rem;
    border: 3px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-light);
}

.file-label:hover {
    border-color: var(--primary-color);
    background: #e3f2fd;
}

.file-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.file-text {
    display: block;
    color: var(--text-dark);
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

.btn-success:hover {
    background: #218838;
}

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

.btn-secondary:hover {
    background: #5a6268;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    animation: progress 1s infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Error Message */
.error-message {
    background: #fee;
    color: var(--danger-color);
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border-left: 4px solid var(--danger-color);
}

/* Preview Section */
.preview-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.preview-container {
    max-width: 100%;
    margin: 1rem 0;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-light);
}

.preview-container img {
    width: 100%;
    height: auto;
    display: block;
}

.preview-info {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 6px;
}

.preview-info p {
    margin: 0.5rem 0;
}

/* Editor Page */
.editor-page {
    background: #2c3e50;
}

.editor-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .editor-container {
        flex-direction: column;
    }
}

/* Canvas Wrapper */
.canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #34495e;
    overflow: hidden;
}

.canvas-toolbar {
    background: #2c3e50;
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 2px solid #1a252f;
}

.tool-btn {
    padding: 0.5rem 1rem;
    background: #34495e;
    color: white;
    border: 1px solid #4a5f7a;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: #4a5f7a;
    transform: translateY(-1px);
}

.tool-btn.danger {
    background: var(--danger-color);
    border-color: #c82333;
}

.tool-btn.danger:hover {
    background: #c82333;
}

.canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 1rem;
    background: #1a252f;
    position: relative;
}

#mapCanvas {
    background: white;
    cursor: crosshair;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: block;
    transition: transform 0.2s ease;
}

#mapCanvas.dragging {
    cursor: move;
}

#mapCanvas.placing {
    cursor: crosshair;
}

/* Tools Panel */
.tools-panel {
    width: 350px;
    background: white;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1024px) {
    .tools-panel {
        width: 100%;
        max-height: 40vh;
    }
}

.tools-panel h2 {
    margin-bottom: 1.5rem;
    color: var(--bg-dark);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.tool-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--bg-dark);
}

/* Icon Palette */
.icon-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.icon-btn {
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    padding: 0.5rem;
}

.icon-btn:hover {
    border-color: var(--primary-color);
    background: #e3f2fd;
    transform: scale(1.05);
}

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

.icon-btn img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Kingdom Inputs */
.kingdom-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.kingdom-inputs input[type="text"] {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.kingdom-inputs input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.kingdom-inputs input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

/* Size Controls */
.size-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.size-controls label {
    font-weight: 600;
    color: var(--bg-dark);
}

.size-controls input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.size-buttons {
    display: flex;
    gap: 0.5rem;
}

.size-buttons .btn-small {
    flex: 1;
    padding: 0.5rem;
    font-size: 1.2rem;
    font-weight: bold;
}

.size-hint {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
    font-style: italic;
}

/* Legend */
.legend-list {
    max-height: 300px;
    overflow-y: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-light);
    border-radius: 6px;
    border-left: 4px solid;
    cursor: pointer;
    transition: all 0.2s ease;
}

.legend-item:hover {
    background: #e3f2fd;
    transform: translateX(4px);
}

.legend-item-selected {
    background: #e3f2fd;
    border-left-width: 6px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend-color {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.legend-text {
    flex: 1;
    font-weight: 500;
}

.legend-delete {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.legend-empty {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: #999;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-dark);
}

.plan-list {
    max-height: 400px;
    overflow-y: auto;
}

.plan-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid var(--primary-color);
}

.plan-item:hover {
    background: #e3f2fd;
    transform: translateX(4px);
}

.plan-item h4 {
    margin-bottom: 0.25rem;
    color: var(--bg-dark);
}

.plan-item p {
    font-size: 0.9rem;
    color: #666;
    margin: 0.25rem 0;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    color: var(--text-light);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

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

.site-footer a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.site-footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.editor-page .site-footer {
    background: rgba(0, 0, 0, 0.3);
    margin: 0;
    border-radius: 0;
}



