/* Territory Planner Specific Styles - Extends styles.css */

/* Grid Controls Section - Match Alliance Section Style */
.grid-controls-section {
    background: #fff8f0;
    padding: 0;
    border-radius: 20px;
    margin-bottom: 30px;
    border: 2px solid rgba(139, 111, 71, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.grid-controls-section h2 {
    background: #d4c4af;
    color: #4a3a2a;
    padding: 15px 15px 15px 60px;
    margin: 0 0 20px 0;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9);
    font-size: 18px;
    border-bottom: 2px solid rgba(139, 111, 71, 0.15);
    font-weight: 800;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.grid-controls-section h2::before {
    content: '🛠️';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 50px;
    background: rgba(255, 255, 255, 0.6);
    border-top-left-radius: 18px;
    border-right: 2px solid rgba(139, 111, 71, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    z-index: 1;
    clip-path: polygon(0 0, 85% 0, 100% 50%, 85% 100%, 0 100%);
}

.grid-controls-section > div {
    padding: 0 20px 20px 20px;
}

.controls-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.controls-buttons button {
    flex: 0 0 auto;
}

.grid-size-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.grid-size-controls label {
    font-weight: bold;
    color: #6b4423;
}

.grid-size-controls input {
    width: 80px;
    padding: 12px;
    border: 2px solid rgba(139, 111, 71, 0.25);
    border-radius: 15px;
    font-size: 16px;
    background: white;
    font-weight: bold;
    color: #4a3428;
}

/* Territory Section - Match Other Sections */
.territory-section {
    background: #fff8f0;
    padding: 0;
    border-radius: 20px;
    margin-bottom: 30px;
    border: 2px solid rgba(139, 111, 71, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.territory-section h2 {
    background: #d4c4af;
    color: #4a3a2a;
    padding: 15px 15px 15px 60px;
    margin: 0 0 20px 0;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9);
    font-size: 18px;
    border-bottom: 2px solid rgba(139, 111, 71, 0.15);
    font-weight: 800;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.territory-section h2::before {
    content: '🗺️';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 50px;
    background: rgba(255, 255, 255, 0.6);
    border-top-left-radius: 18px;
    border-right: 2px solid rgba(139, 111, 71, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    z-index: 1;
    clip-path: polygon(0 0, 85% 0, 100% 50%, 85% 100%, 0 100%);
}

.territory-section > div {
    padding: 0 20px 20px 20px;
}

/* Floating Action Toolbar */
.floating-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.5rem;
    border-radius: 10px;
    border: 2px solid rgba(139, 111, 71, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.action-tool-btn,
.buildings-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    border: 2px solid rgba(139, 111, 71, 0.3);
    border-radius: 8px;
    background: #f5ebe0;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b4423;
    font-weight: 700;
    font-size: 0.9rem;
}

.action-tool-btn:hover,
.buildings-menu-btn:hover {
    background: #e8dcc8;
    border-color: rgba(139, 111, 71, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.action-tool-btn.active {
    background: #45b7d1;
    color: white;
    border-color: #3a9ab8;
}

.buildings-menu-btn {
    position: relative;
}

.buildings-menu-btn .menu-arrow {
    font-size: 0.7em;
    transition: transform 0.2s;
}

.buildings-menu-btn.active .menu-arrow {
    transform: rotate(180deg);
}

.action-tool-btn .tool-icon,
.buildings-menu-btn .tool-icon {
    font-size: 1.3em;
}

/* History Buttons (Undo/Redo) */
.history-buttons {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid rgba(139, 111, 71, 0.2);
}

.history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid rgba(139, 111, 71, 0.3);
    border-radius: 6px;
    background: #f5ebe0;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b4423;
    font-size: 1.2rem;
    font-weight: bold;
}

.history-btn:hover:not(:disabled) {
    background: #e8dcc8;
    border-color: rgba(139, 111, 71, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.history-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Buildings Dropdown Menu */
.buildings-menu {
    display: none;
    background: #fff8f0;
    border: 2px solid rgba(139, 111, 71, 0.3);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.buildings-menu.show {
    display: block;
}

.buildings-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.building-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem;
    border: 2px solid rgba(139, 111, 71, 0.3);
    border-radius: 8px;
    background: #f5ebe0;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b4423;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: left;
}

.building-menu-btn:hover {
    background: #e8dcc8;
    border-color: rgba(139, 111, 71, 0.5);
    transform: translateX(3px);
}

.building-menu-btn.active {
    background: #6c5ce7;
    color: white;
    border-color: #5849c4;
}

.building-menu-btn .tool-icon {
    font-size: 1.5em;
}

/* Canvas Wrapper */
.canvas-wrapper {
    border: 2px solid rgba(139, 111, 71, 0.3);
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: auto;
    margin-bottom: 1rem;
    max-height: 70vh;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

#territory-grid {
    cursor: crosshair;
    display: block;
    transform-origin: 0 0;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #6b4423;
    font-weight: 600;
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid rgba(139, 111, 71, 0.4);
}

.alliance-territory {
    background: rgba(135, 206, 235, 0.7);
}

.buildable-area {
    background: rgba(144, 238, 144, 0.7);
}

.valid-placement {
    background: rgba(46, 204, 113, 0.6);
}

.invalid-placement {
    background: rgba(231, 76, 60, 0.6);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .grid-controls-section h2::before,
    .territory-section h2::before {
        width: 45px;
    }
    
    .controls-buttons {
        justify-content: flex-start;
    }
    
    .grid-size-controls {
        justify-content: flex-start;
    }
    
    .floating-toolbar {
        padding: 0.4rem;
        gap: 0.4rem;
    }
    
    .action-tool-btn,
    .buildings-menu-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .history-btn {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    
    .buildings-menu-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .floating-toolbar {
        padding: 0.3rem;
        gap: 0.3rem;
    }
    
    .action-tool-btn,
    .buildings-menu-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .history-btn {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
    
    .canvas-wrapper {
        max-height: 60vh; /* More screen space for canvas on mobile */
    }
}
