/* Wavecom Desk - Base Styles */
:root {
    --primary: #0056b3;
    --primary-dark: #003d80;
    --primary-light: #e8f0fe;
    --accent: #00a651;
    --danger: #dc3545;
    --warning: #ffc107;
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-300: #ced4da;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo h1 {
    font-size: 1.75rem;
    color: var(--primary);
    font-weight: 700;
}

.login-card .logo p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-group input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.alert-success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--gray-900);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: var(--white);
    background: rgba(255,255,255,0.1);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
}

.main-content {
    flex: 1;
    margin-left: 250px;
}

.topbar {
    background: var(--white);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar .user-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.topbar .user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.btn-logout {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.page-content {
    padding: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding: 0.75rem 1rem;
    }

    .menu-toggle {
        display: block;
    }
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-700);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
}

/* Sidebar sections */
.sidebar-section {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    margin-top: 0.5rem;
}

/* Page header with action button */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header .page-title {
    margin-bottom: 0;
}

/* Button variants */
.btn-accent {
    background: var(--accent);
    color: var(--white);
}

.btn-accent:hover {
    background: #008c44;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

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

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

.btn-warning {
    background: var(--warning);
    color: var(--gray-900);
}

/* Form elements */
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--white);
    outline: none;
    transition: border-color var(--transition);
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 0.5fr;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* Filters row */
.filters-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filters-row .form-select {
    width: auto;
    min-width: 160px;
}

/* Data table */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

.text-center {
    text-align: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #d1e7dd;
    color: #0f5132;
}

.badge-danger {
    background: #f8d7da;
    color: #842029;
}

.badge-warning {
    background: #fff3cd;
    color: #664d03;
}

.badge-info {
    background: #cff4fc;
    color: #055160;
}

/* Card title */
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

/* Profile grid */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.autocomplete-item:hover {
    background: var(--gray-100);
}

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

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 1.5rem;
}

/* Autocomplete */
.autocomplete-wrap {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 150;
    display: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 0.5rem 0.875rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--primary-light);
    color: var(--primary);
}

/* Results header */
.results-header {
    margin-bottom: 0.75rem;
}

.results-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

/* Mappa Copertura */
.mappa-card {
    padding: 0;
    overflow: hidden;
}
.mappa-fullpage {
    margin-bottom: 0;
    border-radius: 0;
    box-shadow: none;
}

.mappa-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}

.mappa-toolbar .form-group-input,
.mappa-toolbar gmp-place-autocomplete {
    width: 100%;
    font-size: 0.85rem;
    outline: none;
}
.mappa-toolbar gmp-place-autocomplete {
    height: 34px;
    --gmpx-font-size-base: 0.85rem;
}

.mappa-toolbar .form-group-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.15);
}

.mappa-container {
    height: calc(100vh - 160px);
    min-height: 400px;
    background: var(--gray-100);
}

.mappa-status {
    font-size: 0.8rem;
    color: var(--gray-500);
    white-space: nowrap;
}

.mappa-status.warning {
    color: var(--warning);
    font-weight: 500;
}

.mappa-status.error {
    color: var(--danger);
    font-weight: 500;
}

.mappa-legend {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.8rem;
    color: var(--gray-700);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot-green { background: #22c55e; }
.legend-dot-red { background: #ef4444; }
.legend-dot-gray { background: #9ca3af; }

.mappa-filters {
    display: flex;
    gap: 2rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    flex-wrap: wrap;
}

.mappa-filters-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.mappa-filters-group strong {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.03em;
}

.mappa-filters-group label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    white-space: nowrap;
}

.mappa-filters-group input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Fix Google Places autocomplete dropdown z-index */
.pac-container {
    z-index: 1100 !important;
}

/* Search form */
.search-form .form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.search-form .form-group input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition);
}

.search-form .form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.15);
}

.search-form .form-group input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

/* Action buttons in tables */
.actions-cell {
    display: flex;
    gap: 0.25rem;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ==================== Geocoding Page ==================== */

.geo-search-card {
    padding: 1rem 1.25rem;
}

.geo-search-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.geo-search-row .geo-field {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.geo-search-row .geo-field-sm {
    min-width: 140px;
    margin-bottom: 0;
}

.geo-search-row .geo-field-btn {
    margin-bottom: 0;
    padding-bottom: 1px;
}

.geo-search-row label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.geo-search-row input,
.geo-search-row select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition);
    background: var(--white);
}

.geo-search-row input:focus,
.geo-search-row select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,86,179,0.1);
}

.geo-search-row input:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

/* Stats bar */
.geo-stats-bar {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.875rem 1.25rem;
    margin-bottom: 1rem;
}

.geo-stats-grid {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.geo-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.geo-stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
}

.geo-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.geo-val-ok { color: var(--accent); }
.geo-val-danger { color: var(--danger); }
.geo-val-warning { color: #e67e00; }

/* Results */
.geo-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.geo-results-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.geo-select-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.geo-selected-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
}

.geo-page-info {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Table */
.geo-table {
    font-size: 0.8rem;
}

.geo-col-check { width: 36px; text-align: center; }
.geo-col-egon { font-size: 0.7rem; }
.geo-col-civ { width: 60px; }
.geo-col-tipo { width: 90px; }
.geo-col-vend { width: 100px; }
.geo-col-coord { min-width: 160px; }
.geo-col-fonte { width: 60px; text-align: center; }
.geo-col-azioni { width: 80px; text-align: center; }

.geo-table .geo-coord-ok { color: var(--accent); font-size: 0.75rem; font-family: monospace; }
.geo-table .geo-coord-dup { color: #e67e00; font-size: 0.75rem; font-family: monospace; }
.geo-table .geo-coord-none { color: var(--gray-300); }

.geo-badge-dup {
    display: inline-block;
    background: #e67e00;
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    margin-left: 4px;
    vertical-align: middle;
}

.geo-badge-source {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.geo-badge-source-google { background: #e8f0fe; color: #1a73e8; }
.geo-badge-source-manual { background: #fef3e2; color: #e67e00; }
.geo-badge-source-of { background: #d1e7dd; color: #0f5132; }
.geo-badge-source-nominatim { background: #f0e6ff; color: #6b21a8; }

.geo-btn-edit {
    padding: 3px 8px;
    font-size: 0.7rem;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.geo-btn-edit:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Pagination */
.geo-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gray-200);
}

.geo-pagination button {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-700);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
}

.geo-pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.geo-pagination button.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.geo-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Modal */
.geo-modal {
    max-width: 480px;
}

.geo-edit-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.geo-edit-addr {
    font-weight: 600;
    font-size: 0.95rem;
}

.geo-edit-egon {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.geo-edit-egon code {
    font-family: monospace;
    background: var(--gray-100);
    padding: 1px 4px;
    border-radius: 3px;
}

.geo-edit-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }

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

    .filters-row {
        flex-direction: column;
    }

    .filters-row .form-select {
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .geo-search-row {
        flex-direction: column;
    }

    .geo-stats-grid {
        gap: 0.75rem;
    }

    .geo-results-header {
        flex-direction: column;
    }
}
