/* ============================================================
   Location Tracker — Main Stylesheet
   ============================================================ */

:root {
    --bg-primary:    #0d0d1a;
    --bg-secondary:  #131326;
    --bg-card:       #1a1a2e;
    --bg-card-hover: #1f1f3a;
    --bg-input:      #12122a;

    --accent:        #7c5cfc;
    --accent-light:  #a78bfa;
    --accent-dark:   #5a3fd4;
    --accent-glow:   rgba(124,92,252,0.3);

    --green:         #34d399;
    --green-bg:      rgba(52,211,153,0.12);
    --red:           #f87171;
    --red-bg:        rgba(248,113,113,0.12);
    --blue:          #60a5fa;
    --blue-bg:       rgba(96,165,250,0.12);

    --text-primary:  #f0f0ff;
    --text-secondary:#a0a0c0;
    --text-muted:    #606080;

    --border:        rgba(255,255,255,0.06);
    --border-light:  rgba(255,255,255,0.12);

    --sidebar-w:     260px;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     20px;

    --shadow-card:   0 4px 24px rgba(0,0,0,0.4);
    --shadow-modal:  0 20px 60px rgba(0,0,0,0.7);
    --transition:    0.2s cubic-bezier(0.4,0,0.2,1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Auth Page
   ============================================================ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 40%, rgba(124,92,252,0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 60%, rgba(96,165,250,0.15) 0%, transparent 50%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-modal);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent), #5a3fd4);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.logo-icon svg { width: 28px; height: 28px; color: #fff; }

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-logo p { color: var(--text-secondary); font-size: 0.875rem; }

/* ============================================================
   Dashboard Layout
   ============================================================ */
.dashboard-body {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent), #5a3fd4);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.sidebar-logo svg { width: 20px; height: 20px; color: #fff; }

.sidebar-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}
.sidebar-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(124,92,252,0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(124,92,252,0.2), rgba(96,165,250,0.1));
    color: var(--accent-light);
    border: 1px solid rgba(124,92,252,0.2);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--red);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition);
}

.btn-logout:hover { background: var(--red-bg); }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* Section */
.section {
    display: none;
    flex-direction: column;
    gap: 24px;
    padding: 28px;
    flex: 1;
}
.section.active { display: flex; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-blue   { background: var(--blue-bg);  color: var(--blue); }
.stat-icon-green  { background: var(--green-bg); color: var(--green); }
.stat-icon-purple { background: var(--accent-glow); color: var(--accent-light); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Table */
.table-wrap { overflow-x: auto; }

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

.data-table th,
.data-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

.link-name { font-weight: 500; color: var(--text-primary); }
.link-sub  { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.slug-code {
    background: rgba(124,92,252,0.1);
    color: var(--accent-light);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.text-muted { color: var(--text-muted); font-size: 0.82rem; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }

.action-btns { display: flex; align-items: center; gap: 6px; }

.btn-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.btn-view:hover  { color: var(--accent-light); border-color: var(--accent); }
.btn-copy:hover  { color: var(--green); border-color: var(--green); }
.btn-delete:hover{ color: var(--red); border-color: var(--red); }

.track-url {
    color: var(--accent-light);
    text-decoration: none;
    font-size: 0.82rem;
    word-break: break-all;
}
.track-url:hover { text-decoration: underline; }

.og-thumb {
    width: 48px;
    height: 28px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-ghost {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover { background: rgba(248,113,113,0.2); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

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

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 10px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea { resize: vertical; min-height: 80px; }

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

.input-prefix {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-prefix:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-prefix span {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    font-size: 0.8rem;
    border-right: 1px solid var(--border);
    white-space: nowrap;
}

.input-prefix input {
    border: none !important;
    box-shadow: none !important;
    background: transparent;
    flex: 1;
}

.req { color: var(--red); }
.mt-2 { margin-top: 8px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

/* Image Upload */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
    overflow: hidden;
}

.image-upload-area:hover {
    border-color: var(--accent);
    background: rgba(124,92,252,0.04);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100% !important;
    height: 100%;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    pointer-events: none;
}

.upload-placeholder svg { color: var(--accent-light); }
.upload-placeholder p { font-size: 0.875rem; color: var(--text-secondary); }
.upload-placeholder span { font-size: 0.75rem; }

.image-preview {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.hidden { display: none !important; }

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    max-width: 580px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-xl { max-width: 900px; }
.modal-sm { max-width: 420px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.93) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

.modal-close {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--red-bg); color: var(--red); border-color: rgba(248,113,113,0.3); }

.modal-body { padding: 24px; }

/* View Locations Layout */
.view-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.map-container {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    height: 320px;
}

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

.locations-table-wrap { overflow-x: auto; }

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
    color: var(--text-muted);
}

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

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

/* ============================================================
   Alerts & Toast
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.alert-error   { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(248,113,113,0.2); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(52,211,153,0.2); }

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 0.875rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-modal);
    transform: translateY(80px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 1000;
    max-width: 320px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(52,211,153,0.3); color: var(--green); }
.toast.error   { border-color: rgba(248,113,113,0.3); color: var(--red); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .form-row { grid-template-columns: 1fr; }
    .section { padding: 16px; }
    .topbar { padding: 12px 16px; }
}
