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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 1.5rem;
}

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

.user-info span {
    font-size: 0.9rem;
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 20px;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background 0.3s;
}

.main-nav a:hover {
    background: rgba(255,255,255,0.1);
}

/* Burger Menu */
.burger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.burger-menu span {
    width: 30px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.burger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translateY(8px);
}

.burger-menu.active span:nth-child(2) {
    opacity: 0;
}

.burger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-8px);
}

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

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-logout {
    background: #e74c3c;
    color: white;
}

.btn-logout:hover {
    background: #c0392b;
}

.btn-edit {
    background: #f39c12;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-edit:hover {
    background: #e67e22;
}

.btn-delete {
    background: #e74c3c;
    color: white;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-delete:hover {
    background: #c0392b;
}

.btn-block {
    width: 100%;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

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

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

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

/* Page Header */
.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    color: #2c3e50;
    font-size: 2rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 500px;
}

.search-box input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #3498db;
}

/* Table */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

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

.streets-table thead {
    background: #34495e;
    color: white;
}

.streets-table th {
    padding: 15px;
    text-align: left;
    font-weight: 500;
}

.streets-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #ecf0f1;
}

.streets-table tbody tr:hover {
    background: #f8f9fa;
}

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

.no-data {
    text-align: center;
    color: #999;
    padding: 40px !important;
}

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

.modal.show {
    display: block;
}

.modal-content {
    background: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideIn 0.3s;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

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

.form-actions .btn {
    flex: 1;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    /* Container & Layout */
    .container {
        padding: 15px;
    }

    /* Header */
    header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .header-content {
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .header-content h1 {
        font-size: 1.25rem;
        order: 1;
    }

    /* Burger Menu - Show on mobile */
    .burger-menu {
        display: flex;
        order: 2;
    }

    /* User info - move to top right */
    .user-info {
        order: 3;
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .user-info span {
        display: none; /* Hide username on very small screens */
    }

    /* Main Navigation - Mobile Dropdown */
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        flex-direction: column;
        gap: 0;
        background: #2c3e50;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, box-shadow 0.3s ease;
        box-shadow: none;
        order: 4;
        z-index: 999;
    }

    .main-nav.active {
        max-height: 200px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }

    .main-nav a {
        width: 100%;
        text-align: left;
        padding: 15px 20px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        border-radius: 0;
    }

    .main-nav a:last-child {
        border-bottom: none;
    }

    /* Page Header */
    .page-header h2 {
        font-size: 1.5rem;
    }

    /* Toolbar */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .search-box {
        max-width: 100%;
        flex-direction: column;
    }

    .search-box input {
        width: 100%;
    }

    .search-box button {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }

    #addStreetBtn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }

    /* Table - Card View for Mobile */
    .table-container {
        padding: 10px;
    }

    .streets-table {
        display: block;
    }

    .streets-table thead {
        display: none;
    }

    .streets-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .streets-table tbody tr {
        display: block;
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        transition: all 0.2s;
    }

    .streets-table tbody tr:hover {
        background: #f8f9fa;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        transform: translateY(-2px);
    }

    .streets-table tbody td {
        display: block;
        padding: 8px 0;
        border: none;
        text-align: left;
    }

    .streets-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #34495e;
        display: inline-block;
        width: 80px;
        margin-right: 10px;
    }

    /* ID Field */
    .streets-table tbody tr td:first-child {
        font-size: 0.9rem;
        color: #666;
        padding-bottom: 5px;
        border-bottom: 1px solid #ecf0f1;
        margin-bottom: 8px;
    }

    .streets-table tbody tr td:first-child::before {
        content: "ID: ";
        font-weight: 500;
        color: #999;
        width: auto;
    }

    /* Street Name */
    .streets-table tbody .street-name {
        font-size: 1.1rem;
        font-weight: 600;
        color: #2c3e50;
        padding: 10px 0;
    }

    .streets-table tbody .street-name::before {
        content: "";
        display: none;
    }

    /* Actions */
    .streets-table .actions {
        display: flex;
        flex-direction: row;
        gap: 10px;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid #ecf0f1;
    }

    .streets-table .actions::before {
        display: none;
    }

    .streets-table .actions .btn {
        flex: 1;
        padding: 12px;
        font-size: 15px;
        font-weight: 500;
    }

    /* No Data */
    .no-data {
        display: block !important;
        text-align: center;
        padding: 30px !important;
    }

    /* Modal */
    .modal-content {
        margin: 5% auto;
        width: 95%;
        max-width: 95%;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-content h3 {
        font-size: 1.3rem;
        margin-bottom: 15px;
        padding-right: 30px;
    }

    .close {
        font-size: 32px;
        right: 15px;
        top: 10px;
    }

    /* Form Actions */
    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }

    /* Search Buttons in Modal */
    .search-buttons-container {
        flex-direction: column;
    }

    .search-btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 15px;
    }

    /* Google Results */
    .google-results-list {
        max-height: 200px;
    }

    .google-result-content {
        padding: 10px 12px;
    }

    .google-result-map-btn {
        min-width: 45px;
        padding: 0 12px;
        font-size: 22px;
    }

    .google-result-street {
        font-size: 14px;
    }

    .google-result-address {
        font-size: 12px;
    }

    /* Login Page */
    .login-box {
        padding: 30px 20px;
    }

    /* Form Container */
    .form-container {
        padding: 20px;
    }
}

/* Extra Small Devices */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .page-header h2 {
        font-size: 1.3rem;
    }

    .modal-content {
        padding: 15px;
    }

    .streets-table tbody tr {
        padding: 12px;
    }

    .btn {
        font-size: 15px;
        padding: 10px 14px;
    }
}

/* Form Container */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 600px;
}

.form-container .form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85rem;
}

/* Sortable Table Headers */
.streets-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s;
}

.streets-table th.sortable:hover {
    background: #2c3e50;
}

.streets-table th.sortable .sort-icon {
    margin-left: 8px;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.streets-table th.sortable:hover .sort-icon {
    opacity: 1;
}

/* Google Maps & OSM Search Integration */
#googleSearchSection {
    margin-top: 10px;
}

.search-buttons-container {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.search-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.search-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.google-loader {
    text-align: center;
    padding: 20px;
    color: #666;
}

.loader-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.google-results {
    margin-top: 15px;
}

.google-results label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #2c3e50;
}

.google-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.google-result-item {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: stretch;

}

.google-result-item:hover {
    border-color: #3498db;
    background: #f0f8ff;
    transform: translateX(3px);
}

.google-result-content {
    flex: 1;
    padding: 12px 15px;
    cursor: pointer;
}

.google-result-content:hover {
    background: rgba(52, 152, 219, 0.05);
}

.google-result-street {
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
    margin-bottom: 4px;
}

.google-result-address {
    font-size: 13px;
    color: #666;
}

.google-result-map-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 0 15px;
    background: #3498db;
    color: white;
    font-size: 24px;
    text-decoration: none;
    border-left: 2px solid #e0e0e0;
    transition: all 0.2s ease;
}

.google-result-map-btn:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.google-result-map-btn:active {
    transform: scale(0.95);
}

.google-error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 15px;
    margin-top: 15px;
    color: #856404;
    font-size: 14px;
}

.google-error strong {
    display: block;
    margin-bottom: 5px;
}

@media (max-width: 768px) {
    .google-results-list {
        max-height: 200px;
    }

    .google-result-content {
        padding: 10px 12px;
    }

    .google-result-map-btn {
        min-width: 45px;
        padding: 0 12px;
        font-size: 22px;
    }

    .google-result-street {
        font-size: 14px;
    }

    .google-result-address {
        font-size: 12px;
    }
}
