/* General Styles */
:root {
    --brand-red: #ed1c24;
    --brand-red-dark: #c9151d;
    --brand-yellow: #fff200;
    --brand-green: #39b54a;
    --brand-cream: #fff8e6;
    --brand-cream-strong: #fff1bf;
    --text-main: #333;
    --text-muted: #777;
    --border-soft: #f0dfb8;
    --surface: #fff;
    --surface-soft: #fffdf5;
    --shadow-soft: 0 2px 10px rgba(237, 28, 36, 0.08);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--brand-cream);
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: var(--brand-red);
    transition: color 0.3s;
}

a:hover {
    color: var(--brand-red-dark);
}

/* Navbar */
.navbar {
    background: var(--brand-red-dark);
    padding: 15px 0;
    box-shadow: var(--shadow-soft);
    border-bottom: 4px solid var(--brand-red);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    color: white;
    font-size: 24px;
    font-weight: bold;
}

.logo i {
    margin-right: 10px;
}

.logo img {
    max-width: 100%;
    height: auto;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.btn-logout {
    background: white;
    color: var(--brand-red-dark);
    padding: 8px 16px;
    border-radius: 5px;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: var(--brand-cream);
    color: var(--brand-red-dark);
}

/* Main Container */
.main-container {
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Content Wrapper */
.content-wrapper {
    display: flex;
    gap: 20px;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--surface-soft);
    padding: 20px;
    border-right: 1px solid var(--border-soft);
}

.sidebar-menu {
    list-style: none;
}

.menu-item {
    margin-bottom: 5px;
}

.menu-item a {
    display: block;
    padding: 12px 15px;
    border-radius: 5px;
    color: var(--text-main);
    transition: all 0.3s;
}

.menu-item a:hover,
.menu-item a.active {
    background: var(--brand-red);
    color: white;
}

.menu-item i {
    margin-right: 10px;
    width: 20px;
}

/* Content */
.content {
    flex: 1;
    min-width: 0;
    padding: 30px;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-soft);
}

.page-header h1 {
    font-size: 28px;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(237, 28, 36, 0.18);
}

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

.btn-primary:hover {
    background: var(--brand-red-dark);
    color: white;
}

.btn-secondary {
    background: var(--brand-cream-strong);
    color: var(--brand-red);
    border: 1px solid #ffe36b;
}

.btn-secondary:hover {
    background: var(--brand-yellow);
    color: var(--brand-red-dark);
}

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

.btn-success:hover,
.btn-info:hover {
    background: #2f963e;
    color: white;
}

.btn-info {
    background: var(--brand-green);
    color: white;
}

.btn-warning {
    background: var(--brand-yellow);
    color: #5c1800;
}

.btn-warning:hover {
    background: #ffe36b;
    color: #5c1800;
}

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

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

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

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

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--brand-red);
}

.stat-icon.accent-red {
    background: rgba(237, 28, 36, 0.1);
}

.stat-icon.accent-yellow {
    background: rgba(255, 242, 0, 0.3);
}

.stat-icon.accent-green {
    background: rgba(57, 181, 74, 0.14);
    color: var(--brand-green);
}

.stat-content h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.stat-number {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-main);
}

/* Search Box */
.search-box {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 10px;
}

.search-form input,
.search-form .search-select {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    font-size: 14px;
    background: white;
    color: var(--text-main);
    font-family: inherit;
}

.search-form .search-select {
    flex: 0 0 180px;
    appearance: none;
    padding-right: 36px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--brand-red) 50%),
        linear-gradient(135deg, var(--brand-red) 50%, transparent 50%);
    background-position:
        calc(100% - 19px) 18px,
        calc(100% - 13px) 18px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    font-weight: 600;
    box-shadow: inset 0 1px 2px rgba(237, 28, 36, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.search-form input:focus,
.search-form .search-select:focus {
    outline: none;
    border-color: var(--brand-red);
    background-color: #fffefa;
    box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.12);
}

.search-form button {
    background: var(--brand-red);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.search-form button:hover {
    background: var(--brand-red-dark);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.table thead {
    background: var(--surface-soft);
    border-bottom: 2px solid var(--border-soft);
}

.table th {
    padding: 5px;
    text-align: left;
    font-weight: 600;
    color: var(--text-main);
}

.table td {
    padding: 5px;
    font-weight: 200;
    font-size: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.table tbody tr:hover {
    background: #fff4d6;
}

.pagination-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 14px 0;
    padding: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.pagination-length-form,
.pagination-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-length-form label,
.pagination-summary {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

.pagination-length-form select {
    height: 38px;
    padding: 8px 30px 8px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    background: white;
    color: var(--text-main);
    font: inherit;
}

.pagination-length-form select:focus {
    outline: none;
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.12);
}

.pagination-link,
.pagination-ellipsis {
    min-width: 36px;
    height: 36px;
    padding: 8px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    background: white;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.pagination-link:hover,
.pagination-link.active {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: white;
}

.pagination-link.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.pagination-ellipsis {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}

/* Forms */
.form-container {
    background: var(--surface);
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
}

.form-vertical {
    display: flex;
    flex-direction: column;
}

.form-section {
    margin-bottom: 30px;
}

.form-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-soft);
    color: var(--text-main);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.12);
}

.form-group small {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 12px;
}

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

/* Details Container */
.details-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.details-section {
    background: var(--surface);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
}

.details-section h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: var(--text-main);
}

.detail-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item label {
    font-weight: 600;
    color: var(--brand-red);
    margin-bottom: 5px;
    font-size: 14px;
}

.detail-item p {
    color: var(--text-main);
    line-height: 1.6;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert ul {
    margin-left: 20px;
    margin-top: 10px;
}

/* Quick Actions */
.quick-actions {
    margin-top: 30px;
}

.quick-actions h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-main);
}

.action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.map-content {
    max-height: none;
    padding: 24px;
}

.network-map-shell {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 15px;
    background: var(--surface-soft);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.map-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.map-place-search {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px;
    background: linear-gradient(180deg, #fffdf5 0%, #fff8e6 100%);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(237, 28, 36, 0.06);
}

.map-select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-select-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--brand-red-dark);
    text-transform: uppercase;
}

.map-select-group select,
.map-select-group input {
    min-width: 180px;
    height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    background: white;
    color: var(--text-main);
    font: inherit;
    box-shadow: inset 0 1px 2px rgba(237, 28, 36, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.map-select-group select {
    appearance: none;
    padding-right: 34px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--brand-red) 50%),
        linear-gradient(135deg, var(--brand-red) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 18px,
        calc(100% - 12px) 18px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.map-select-group select:focus,
.map-select-group input:focus {
    outline: none;
    border-color: var(--brand-red);
    background-color: #fffefa;
    box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.12);
}

.map-select-group.compact input {
    min-width: 96px;
    width: 96px;
}

.map-place-search .btn {
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 700;
}

.map-filter,
.map-category-filter {
    padding: 10px 14px;
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    background: white;
    color: var(--text-main);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}

.map-filter.active,
.map-filter:hover,
.map-category-filter.active,
.map-category-filter:hover {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: white;
}

.map-counts {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 14px;
}

.network-map-grid {
    display: grid;
    grid-template-columns: minmax(760px, 1fr) 300px;
    gap: 15px;
    min-height: 760px;
}

.network-map-canvas {
    min-height: 760px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff5d8;
}

.map-location-panel {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 760px;
}

.map-location-panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-soft);
}

.map-location-panel-header h2 {
    font-size: 18px;
    margin-bottom: 5px;
}

.map-location-panel-header p {
    color: var(--text-muted);
    font-size: 13px;
}

.map-location-list {
    overflow-y: auto;
    padding: 10px;
}

.map-load-status {
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: 13px;
    border-bottom: 1px solid var(--border-soft);
}

.map-location-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    color: var(--text-main);
}

.map-location-item:hover {
    background: #fff4d6;
    color: var(--text-main);
}

.map-location-item strong,
.map-location-item small {
    display: block;
}

.map-location-item small {
    color: var(--text-muted);
    margin-top: 3px;
}

.map-location-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex: 0 0 34px;
}

.map-location-serial {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex: 0 0 34px;
    font-weight: 800;
    font-size: 13px;
}

.map-location-icon.distributor,
.map-type-pill.distributor,
.map-location-serial.distributor {
    background: var(--brand-red);
}

.map-location-icon.dealer,
.map-type-pill.dealer,
.map-location-serial.dealer {
    background: var(--brand-green);
}

.map-type-pill {
    display: inline-flex;
    color: white;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    margin-bottom: 8px;
}

.map-info-window {
    max-width: 260px;
}

.map-info-window h3 {
    margin: 0 0 6px;
    font-size: 17px;
}

.map-info-window p {
    margin: 0 0 7px;
    line-height: 1.35;
}

.map-marker-label {
    position: absolute;
    min-width: 28px;
    padding: 4px 7px;
    background: rgba(255, 255, 255, 0.95);
    border-left: 4px solid var(--brand-red);
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    color: #222;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    text-align: center;
    pointer-events: none;
}

.map-empty-state {
    padding: 18px;
    color: var(--text-muted);
    text-align: center;
}

/* Footer */
.footer {
    background: var(--surface-soft);
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-soft);
    color: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-container,
    .nav-container {
        max-width: 100%;
    }

    .network-map-grid {
        grid-template-columns: minmax(0, 1fr) 280px;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 10px 0;
    }

    .nav-container {
        align-items: flex-start;
        gap: 12px;
        padding: 0 12px;
    }

    .logo img {
        height: 58px !important;
        width: auto;
    }

    .nav-menu {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
        text-align: right;
    }

    .user-info {
        font-size: 12px;
        line-height: 1.35;
    }

    .main-container {
        padding: 12px;
    }

    .content-wrapper {
        flex-direction: column;
        gap: 0;
        border-radius: 8px;
    }

    .sidebar {
        width: 100%;
        padding: 12px;
        border-right: none;
        border-bottom: 1px solid var(--border-soft);
    }

    .sidebar-menu {
        display: flex;
        gap: 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .menu-item {
        margin-bottom: 0;
        flex: 0 0 auto;
        min-width: 145px;
    }

    .menu-item a {
        padding: 10px 12px;
        white-space: nowrap;
    }

    .content {
        padding: 18px;
        max-height: none;
        overflow-y: visible;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions a {
        width: 100%;
        text-align: center;
    }

    .detail-row,
    .form-row {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .form-container,
    .details-section {
        padding: 18px;
    }

    .form-actions,
    .search-form,
    .action-buttons {
        flex-direction: column;
    }

    .form-actions .btn,
    .search-form button,
    .action-buttons .btn {
        width: 100%;
        text-align: center;
    }

    .search-form input,
    .search-form .search-select {
        width: 100%;
        flex: 1 1 auto;
    }

    .network-map-grid {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .network-map-canvas,
    .map-location-panel {
        min-height: 420px;
    }

    .map-toolbar {
        align-items: stretch;
        padding: 12px;
    }

    .map-filters,
    .map-place-search,
    .map-counts {
        width: 100%;
    }

    .map-place-search .btn,
    .map-select-group,
    .map-select-group select {
        width: 100%;
    }

    .map-filter,
    .map-category-filter {
        flex: 1 1 140px;
    }

    .table {
        font-size: 12px;
        min-width: 680px;
    }

    .table th,
    .table td {
        padding: 8px;
    }

    .pagination-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination-length-form,
    .pagination-links {
        width: 100%;
    }

    .pagination-length-form select {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .nav-container {
        flex-direction: column;
        align-items: center;
    }

    .nav-menu {
        width: 100%;
        align-items: center;
        text-align: center;
    }

    .btn-logout {
        width: 100%;
        text-align: center;
    }

    .content {
        padding: 14px;
    }

    .page-header h1 {
        font-size: 23px;
    }

    .stat-card {
        align-items: flex-start;
        padding: 16px;
    }

    .network-map-canvas,
    .map-location-panel {
        min-height: 360px;
    }
}
