/* APRS Tracking System Styles */

/* Layout */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

/* Login page specific */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f4f4f4;
}

.login-container {
    background-color: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
    font-weight: 600;
}

.login-container .btn {
    width: 100%;
    background-color: #007bff;
    color: white;
    font-size: 16px;
    padding: 14px;
    margin-top: 10px;
}

.login-container .btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 1rem;
    font-size: 14px;
}

/* Admin pages specific */
body.admin-page {
    padding: 20px;
    background-color: #f4f4f4;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navigation */
.nav-links {
    margin-bottom: 20px;
}

.nav-links a {
    color: #007bff;
    text-decoration: none;
    margin-right: 15px;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* Dashboard Layout */
body.dashboard-page {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    height: 100vh;
    background-color: #f5f5f5;
    overflow: hidden;
    display: grid;
    grid-template-columns: 300px 1fr;
    grid-template-rows: 100vh;
}

body.dashboard-page #sidebar {
    background-color: #f8f9fa;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

body.dashboard-page #map-container {
    background-color: white;
    height: 100vh;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

.dashboard {
    display: flex;
    gap: 20px;
    height: calc(100vh - 100px);
}

.sidebar {
    width: 300px;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.map-container {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

/* Device List */
.device-list h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.user-item {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.user-item label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-icon {
    width: 48px;
    height: 48px;
    background-image: url('https://raw.githubusercontent.com/hessu/aprs-symbols/f2286a9cd43eb6ba4501250b4c39fff111e3796c/png/aprs-symbols-48-0.png');
    background-repeat: no-repeat;
    flex-shrink: 0;
}

.user-item input[type="checkbox"] {
    margin: 0;
}

.user-name {
    margin-left: 4px;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slider-container {
    padding: 20px;
    background: white;
    border-radius: 4px;
    margin-top: 20px;
}

#time-slider {
    margin: 20px 0;
}

.logout-btn {
    background-color: #dc3545;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: auto;
    text-align: center;
    text-decoration: none;
}

.logout-btn:hover {
    background-color: #c82333;
}

.device-item {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.device-item:last-child {
    border-bottom: none;
}

.device-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0; /* Allow flex items to shrink */
}

.device-row label {
    flex: 1;
    min-width: 0; /* Allow label to shrink */
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

/* APRS Icon - Single source of truth */
.device-icon,
.user-icon,
.icon-preview {
    width: 48px;
    height: 48px;
    background-image: url('./images/default.png');
    background-repeat: no-repeat;
    background-size: 768px 288px; /* 16 icons wide * 48px = 768px, 6 icons high * 48px = 288px */
    flex-shrink: 0;
}

.color-preview {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.device-name {
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    word-break: break-word;
}

.last-seen {
    font-size: 12px;
    color: #666;
    text-align: right;
    flex-shrink: 0;
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.last-seen > div {
    white-space: nowrap;
    line-height: 1.4;
    text-align: right;
}

.last-seen.offline {
    color: #dc3545;
}

/* Time Slider */
.time-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.time-controls h4 {
    margin: 0 0 10px 0;
    color: #333;
}

#time-slider {
    width: 100%;
    margin: 10px 0;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

tr:hover {
    background-color: #f5f5f5;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    min-width: 120px;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    outline: 0;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Input styling for login form */
input[type="text"], 
input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
}

input[type="text"]:focus, 
input[type="password"]:focus {
    outline: 0;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Device Assignment */
.device-assignment {
    display: flex;
    align-items: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    background: #f9f9f9;
}

.device-assignment:hover {
    background: #f0f0f0;
}

.device-assignment input[type="checkbox"] {
    margin-right: 10px;
}

.device-assignment .device-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.device-assignment .device-info .device-icon {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .map-container {
        height: 400px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-20 {
    margin-top: 20px;
}

.hidden {
    display: none;
}

/* Time Controls Styling */
.time-controls-container {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.time-controls-container h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
}

.calendar-container {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.calendar-nav-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.calendar-nav-btn:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.calendar-month-year {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.date-calendar {
    font-size: 12px;
}

.calendar-header {
    text-align: center;
    margin-bottom: 10px;
}

.calendar-month {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 5px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 500;
    color: #666;
    padding: 4px;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    border: 1px solid transparent;
}

.calendar-day.empty {
    cursor: default;
    background: transparent;
}

.calendar-day.has-data {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.calendar-day.has-data:hover {
    background-color: #c3e6cb;
    transform: scale(1.05);
}

.calendar-day.no-data {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.calendar-day.no-data:hover {
    background-color: #f5c6cb;
    transform: scale(1.05);
}

.calendar-day.today {
    border: 2px solid #007bff;
    font-weight: 700;
}

.calendar-day.today.has-data {
    background-color: #007bff;
    color: white;
}

.calendar-day.today.no-data {
    background-color: #6c757d;
    color: white;
}

.calendar-day.selected {
    border: 2px solid #007bff !important;
    font-weight: 700;
}

.calendar-day.selected.has-data {
    background-color: #007bff;
    color: white;
}

.calendar-day.selected.no-data {
    background-color: #6c757d;
    color: white;
}

.time-range-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.time-slider-group {
    display: flex;
    flex-direction: column;
}

.time-slider-group label {
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.time-slider-group label span {
    color: #007bff;
    font-weight: 600;
}

#time-range-slider {
    margin: 15px 0 25px 0;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
}

.noUi-connect {
    background: #007bff;
}

.noUi-handle {
    background: #007bff;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    top: -6px;
}

.noUi-handle:before,
.noUi-handle:after {
    background: #fff;
}

.noUi-handle:hover {
    background: #0056b3;
}

.noUi-handle:active {
    background: #004085;
}

.noUi-tooltip {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    padding: 4px 8px;
}

.noUi-tooltip:before {
    border-top-color: #007bff;
}

/* Settings Page Styles */
.settings-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.settings-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.settings-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.settings-form {
    max-width: 400px;
}

.device-visibility-item {
    transition: all 0.2s ease;
}

.device-visibility-item:hover {
    background: #f0f8ff !important;
    border-color: #007bff !important;
}

.device-visibility-item .device-icon {
    width: 24px;
    height: 24px;
    background-image: url('images/symbols.png');
    background-size: 816px 24px;
    display: inline-block;
    margin-right: 10px;
    flex-shrink: 0;
}

.device-visibility-item .color-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid #ddd;
}

/* Admin Section Styles */
.admin-section {
    border-left: 4px solid #dc3545;
}

.admin-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.admin-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    min-height: 120px;
    justify-content: center;
}

.admin-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    background: linear-gradient(135deg, #0056b3, #004085);
    color: white;
    text-decoration: none;
}

.admin-link .admin-icon {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.admin-link small {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin-top: 5px;
    line-height: 1.3;
}

/* Navigation Logout Styling */
.nav-links a[href="logout.php"] {
    color: #dc3545;
    font-weight: 500;
}

.nav-links a[href="logout.php"]:hover {
    color: #c82333;
    background-color: rgba(220, 53, 69, 0.1);
}

/* Admin Management Section */
.admin-management {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.admin-management .admin-links {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.admin-management .admin-link {
    min-width: 200px;
    text-align: center;
    padding: 15px 20px;
}