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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8fafc;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    color: white;
    text-decoration: none;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.header-left p {
    opacity: 0.9;
    font-size: 14px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Menu de Navegação */
.main-menu {
    background: white;
    border-bottom: 2px solid #e5e7eb;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 62px;
    z-index: 99;
}

.menu-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.menu-list {
    list-style: none;
    display: flex;
    gap: 0;
    margin: 0;
    padding: 0;
}

.menu-item {
    flex: 0;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.menu-item a:hover {
    color: #667eea;
    background: #f8f9fa;
}

.menu-item.active a {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f8f9fa;
}

.menu-icon {
    font-size: 18px;
}

.menu-title {
    font-size: 14px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 2px;
    width: fit-content;
}

.role-admin {
    background: rgba(251, 191, 36, 0.25);
    color: #fde68a;
    border: 1px solid rgba(251, 191, 36, 0.4);
}

.role-user {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.logout-btn, .login-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.logout-btn:hover, .login-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Navigation Menu */
.nav-menu {
    background: white;
    border-bottom: 2px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    color: #6b7280;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    color: #667eea;
    background: #f8f9fa;
}

.nav-item.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.nav-icon {
    font-size: 18px;
}

.nav-text {
    font-size: 15px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 200px);
}

/* Footer */
.footer {
    background: #1f2937;
    color: white;
    padding: 30px 0;
    margin-top: 50px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.footer-content p {
    margin: 5px 0;
    opacity: 0.8;
}

.footer-content p:first-child {
    font-weight: 600;
    opacity: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
    border-left: 4px solid #667eea;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 8px;
}

.stat-label {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}

.main-grid.full-width {
    grid-template-columns: 1fr;
}

/* Map Section */
.map-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

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

#map {
    height: 600px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #1f2937;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

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

/* Terrain List */
.terrain-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.terrain-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.terrain-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.terrain-details {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.terrain-actions {
    display: flex;
    gap: 8px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.empty-state h4 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #374151;
}

.empty-state p {
    font-size: 14px;
}

/* Alerts */
.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    min-width: 300px;
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Guest Banner */
.guest-banner {
    background: #fef3c7;
    color: #92400e;
    padding: 12px 20px;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.guest-banner a {
    color: #92400e;
    text-decoration: underline;
}

/* Admin Claim Banner */
.admin-claim-banner {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
}

.admin-claim-content {
    display: flex;
    align-items: center;
    gap: 25px;
    max-width: 900px;
    margin: 0 auto;
}

.admin-claim-icon {
    font-size: 64px;
    line-height: 1;
}

.admin-claim-text {
    flex: 1;
}

.admin-claim-text h3 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #78350f;
}

.admin-claim-text p {
    font-size: 16px;
    color: #92400e;
    margin: 0;
}

.admin-claim-banner .btn {
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.admin-claim-banner .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* Limited Info Overlay */
.limited-info {
    position: relative;
}

.limited-info::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(3px);
    border-radius: 8px;
    pointer-events: none;
}

/* ── Leaflet Layers Control ───────────────────────────── */
/* collapsed:false — painel sempre expandido, estilo limpo */
.leaflet-control-layers {
    border-radius: 10px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,.15) !important;
    border: 1px solid #e5e7eb !important;
    font-family: inherit;
    font-size: 13px;
    min-width: 160px;
}
.leaflet-control-layers-expanded {
    padding: 10px 14px !important;
}
.leaflet-control-layers-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
}
.leaflet-control-layers-separator {
    border-top: 1px solid #e5e7eb;
    margin: 6px 0;
}
/* Título "Camadas base" / "Overlays" */
.leaflet-control-layers-base::before,
.leaflet-control-layers-overlays::before {
    content: attr(aria-label);
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    #map {
        height: 400px;
    }
}

/* Páginas */
.page-content {
    padding: 20px 0;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 28px;
    color: #1f2937;
    margin-bottom: 8px;
}

.page-header p {
    color: #6b7280;
    font-size: 16px;
}

/* Terrains Grid */
.terrains-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.terrain-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.terrain-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.terrain-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.terrain-card-header h3 {
    font-size: 18px;
    color: #1f2937;
    margin: 0;
}

.terrain-badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.terrain-card-description {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.terrain-card-meta {
    color: #9ca3af;
    font-size: 13px;
    margin-bottom: 15px;
}

.terrain-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Empty State Large */
.empty-state-large {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state-large h3 {
    font-size: 24px;
    color: #374151;
    margin-bottom: 12px;
}

.empty-state-large p {
    color: #6b7280;
    font-size: 16px;
    margin-bottom: 24px;
}

/* Stats Grid Large */
.stats-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card-primary { border-left-color: #667eea; }
.stat-card-success { border-left-color: #10b981; }
.stat-card-info { border-left-color: #3b82f6; }
.stat-card-warning { border-left-color: #f59e0b; }
.stat-card-danger { border-left-color: #ef4444; }

.stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.stat-content {
    flex: 1;
}

/* Charts */
.chart-container {
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table th,
.stats-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.stats-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #374151;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    transition: width 0.3s;
}

/* Recent Terrains List */
.recent-terrains-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-terrain-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.recent-terrain-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-terrain-info strong {
    color: #1f2937;
}

.recent-terrain-info span {
    color: #6b7280;
    font-size: 13px;
}

.recent-terrain-date {
    color: #9ca3af;
    font-size: 13px;
}

/* Profile */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.profile-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 20px;
}

.profile-details {
    width: 100%;
}

.profile-detail-item {
    padding: 15px 0;
    border-bottom: 1px solid #e5e7eb;
}

.profile-detail-item:last-child {
    border-bottom: none;
}

.profile-detail-item label {
    display: block;
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 4px;
}

.profile-detail-item strong {
    color: #1f2937;
    font-size: 16px;
}

.profile-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.profile-stat-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.profile-stat-icon {
    font-size: 32px;
}

.profile-stat-content {
    flex: 1;
}

.profile-stat-number {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
}

.profile-stat-label {
    color: #6b7280;
    font-size: 14px;
}

.profile-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Settings */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #e5e7eb;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-info {
    flex: 1;
}

.setting-info strong {
    display: block;
    color: #1f2937;
    margin-bottom: 4px;
}

.setting-info p {
    color: #6b7280;
    font-size: 13px;
    margin: 0;
}

.setting-control {
    display: flex;
    align-items: center;
}

.form-control,
.form-control-color {
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
}

.form-control-color {
    width: 60px;
    height: 40px;
    padding: 4px;
}

.form-range {
    width: 150px;
    margin-right: 10px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.danger-zone {
    border: 2px solid #ef4444;
    border-radius: 12px;
}

.danger-zone h3 {
    color: #ef4444;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Footer */
.footer {
    background: #1f2937;
    color: white;
    padding: 30px 0;
    margin-top: 60px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 30px;
}

.footer-left p,
.footer-right p {
    margin: 5px 0;
    opacity: 0.8;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 1;
}

/* Error Page */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.error-content {
    text-align: center;
    padding: 40px;
}

.error-code {
    font-size: 120px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 20px;
}

.error-content h2 {
    font-size: 32px;
    color: #1f2937;
    margin-bottom: 16px;
}

.error-content p {
    color: #6b7280;
    font-size: 18px;
    margin-bottom: 30px;
}

.error-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Responsive Updates */
@media (max-width: 768px) {
    .menu-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .menu-item a {
        white-space: nowrap;
    }
    
    .profile-grid,
    .profile-forms,
    .footer-content {
        grid-template-columns: 1fr;
    }
    
    .terrains-grid {
        grid-template-columns: 1fr;
    }
}