/* Navi Web - Main Styles */

:root {
    --primary: #0066cc;
    --primary-dark: #004999;
    --primary-light: #e6f0ff;
    --secondary: #00a86b;
    --danger: #dc3545;
    --warning: #ffc107;
    --dark: #1a1a2e;
    --gray-900: #212529;
    --gray-700: #495057;
    --gray-500: #6c757d;
    --gray-300: #dee2e6;
    --gray-100: #f8f9fa;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-100);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

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

.btn-secondary:hover {
    background: var(--gray-500);
    color: var(--white);
}

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 1.125rem;
}

.btn-block {
    display: block;
    width: 100%;
}

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

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

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

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--gray-500);
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-300);
    background: var(--gray-100);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-300);
    background: var(--gray-100);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-sm {
    max-width: 500px;
}

.flex {
    display: flex;
}

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

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

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--gray-500);
}

.text-primary {
    color: var(--primary);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--secondary);
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.p-2 {
    padding: 1rem;
}

.p-3 {
    padding: 1.5rem;
}

.hidden {
    display: none !important;
}

/* ==================== */
/* Landing Page */
/* ==================== */

.landing-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.landing-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.logo span {
    color: var(--secondary);
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--dark) 0%, #16213e 100%);
    color: var(--white);
    padding-top: 80px;
}

.hero-content {
    max-width: 600px;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.features {
    padding: 5rem 0;
}

.features h2 {
    text-align: center;
    margin-bottom: 3rem;
}

.feature-card {
    text-align: center;
    padding: 2rem;
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--gray-500);
}

/* ==================== */
/* Auth Pages */
/* ==================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, #16213e 100%);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-header {
    padding: 2rem;
    text-align: center;
    background: var(--gray-100);
}

.auth-header .logo {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-body {
    padding: 2rem;
}

.auth-footer {
    padding: 1rem 2rem;
    text-align: center;
    background: var(--gray-100);
    border-top: 1px solid var(--gray-300);
}

.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-300);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    font-weight: 500;
    color: var(--gray-500);
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

/* ==================== */
/* App Layout */
/* ==================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

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

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

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    transition: var(--transition);
    text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    text-decoration: none;
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
}

.user-plan {
    font-size: 0.75rem;
    opacity: 0.7;
    text-transform: uppercase;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    min-height: 100vh;
}

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

.topbar h1 {
    font-size: 1.5rem;
    margin: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.page-content {
    padding: 1.5rem;
}

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

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

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

    .menu-toggle {
        display: block;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        display: none;
    }

    .sidebar-overlay.open {
        display: block;
    }
}

/* ==================== */
/* Dashboard */
/* ==================== */

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

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.3;
    float: right;
}

/* ==================== */
/* Tracks List */
/* ==================== */

.tracks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tracks-filters {
    display: flex;
    gap: 0.5rem;
}

.track-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.track-item {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.track-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.track-item-content {
    display: flex;
    gap: 1rem;
    padding: 1rem;
}

.track-preview {
    width: 60px;
    height: 60px;
    background: #001f3f;
    /* Navy Blue */
    border-radius: var(--radius);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
}

.track-preview.loading-preview {
    opacity: 0.5;
}

.track-preview.loading-preview::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.track-preview svg {
    width: 100%;
    height: 100%;
}

.preview-error {
    font-size: 10px;
    color: var(--gray-500);
}

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


.track-preview canvas {
    width: 100%;
    height: 100%;
}

.track-info {
    flex: 1;
    min-width: 0;
}

.track-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-date {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.track-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
}

.track-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.track-stat-value {
    font-weight: 600;
}

.track-stat-label {
    color: var(--gray-500);
}

.track-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--gray-100);
    border-top: 1px solid var(--gray-300);
}

/* ==================== */
/* Track Detail */
/* ==================== */

.track-detail-header {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.track-detail-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.track-detail-title h1 {
    margin: 0;
}

.track-detail-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.track-detail-stat {
    text-align: center;
}

.track-detail-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.track-detail-stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.map-container {
    height: 400px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    position: relative;
}

.map-controls,
.map-style-selector {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.map-controls select,
.map-style-selector select {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    cursor: pointer;
}

.map-controls select:focus,
.map-style-selector select:focus {
    outline: 2px solid var(--primary);
}

.nautical-toggle {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.nautical-toggle input {
    cursor: pointer;
}

.nautical-toggle span {
    color: var(--gray-700);
}

#map {
    width: 100%;
    height: 100%;
}

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

.chart-container h3 {
    margin-bottom: 1rem;
}

#speedChart {
    max-height: 300px;
}

.unit-controls {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.unit-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.unit-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.unit-selector {
    display: inline-flex;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-300);
}

.unit-btn {
    background: var(--white);
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--gray-700);
    font-size: 0.875rem;
    transition: var(--transition);
    border-left: 1px solid var(--gray-300);
}

.unit-btn:first-child {
    border-left: none;
}

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

.unit-btn.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* ==================== */
/* Empty States */
/* ==================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* ==================== */
/* Loading & Alerts */
/* ==================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

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

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

.alert-info {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary);
}

/* ==================== */
/* Modal */
/* ==================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.open .modal {
    transform: scale(1);
}

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

.modal-header h2 {
    margin: 0;
}

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

.modal-body {
    padding: 1.5rem;
}

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

/* ==================== */
/* Waypoints */
/* ==================== */

.waypoint-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.waypoint-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.waypoint-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.waypoint-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.waypoint-name {
    font-weight: 600;
    flex: 1;
}

.waypoint-coords {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-family: monospace;
}

/* ==================== */
/* Vessels */
/* ==================== */

.vessel-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.vessel-image {
    height: 150px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 3rem;
}

.vessel-body {
    padding: 1.5rem;
}

.vessel-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.vessel-type {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.vessel-specs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    font-size: 0.875rem;
}

.vessel-spec-label {
    color: var(--gray-500);
}

.vessel-spec-value {
    font-weight: 600;
}

.vessel-default-badge {
    display: inline-block;
    background: var(--secondary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* ==================== */
/* Profile */
/* ==================== */

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

.profile-section h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-300);
}

/* Public track view */
.public-track-page {
    min-height: 100vh;
    background: var(--gray-100);
}

.public-track-nav {
    background: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.public-track-content {
    padding: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}