/* ---------------------------------------------------------------
   Root variables – easy theming & timeless radio‑amateur look
   --------------------------------------------------------------- */
:root {
    --color-primary: #2c3e50; /* deep blue‑gray, classic ham vibe */
    --color-primary-dark: #1a252f;
    --color-primary-light: #3e5a71;
    --color-accent: #e67e22; /* warm amber for highlights */
    --color-bg: #f4f4f4;
    --color-surface: #ffffff;
    --color-text: #333333;
    --color-muted: #777777;
    --radius: 6px;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    --transition: 0.2s ease-in-out;
    --tap-min-height: 44px; /* minimum touch target size */
}

/* ---------------------------------------------------------------
   Global resets & base styles (using variables)
   --------------------------------------------------------------- */
body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
}

/* Header */
header {
    background-color: var(--color-primary);
    color: #fff;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

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

/* ---------------------------------------------------------------
   Navigation – icons + responsive behaviour
   --------------------------------------------------------------- */
nav a {
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    transition: var(--transition);
}
nav a:hover {
    background-color: var(--color-primary-light);
}

/* ---------------------------------------------------------------
   Buttons – unified .btn class (all <button> inherit this)
   --------------------------------------------------------------- */
button,
.btn {
    background-color: var(--color-primary);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 1rem;
    min-height: var(--tap-min-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}
button:hover,
.btn:hover {
    background-color: var(--color-primary-dark);
}

/* Danger / delete button – still based on .btn */
.delete-log-btn {
    background-color: #dc3545;
}
.delete-log-btn:hover {
    background-color: #c82333;
}

/* Language switcher – outline style */
#language-switcher button {
    background: none;
    border: 1px solid #fff;
    color: #fff;
    margin-left: 0.5rem;
    min-height: var(--tap-min-height);
    padding: 0.5rem 0.8rem;
}

/* ---------------------------------------------------------------
   Forms – spacing & larger touch targets
   --------------------------------------------------------------- */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-muted);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: var(--radius);
    font-size: 1rem;
    box-sizing: border-box;
}

/* ---------------------------------------------------------------
   Tables – scrollable on small screens, clean look
   --------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}
th,
td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
th {
    background-color: var(--color-primary-light);
    color: #fff;
}

/* Action column – keep buttons on one line */
td:last-child,
th:last-child {
    white-space: nowrap;
    min-width: 150px;
}
td:last-child {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    align-items: center;
}

/* ---------------------------------------------------------------
   Loader – reusable global overlay
   --------------------------------------------------------------- */
#global-loader {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none; /* show via JS when needed */
    align-items: center;
    justify-content: center;
    z-index: 3000;
    font-size: 1.5rem;
    color: var(--color-primary-dark);
}
#global-loader::after {
    content: "";
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--color-primary-light);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------------------------------------------------------------
   Responsive tweaks – mobile first
   --------------------------------------------------------------- */
@media (max-width: 600px) {
    #nav-toggle {
        display: inline-block;
    }
    header nav {
        display: none;
        flex-direction: column;
        width: 100%;
        background: var(--color-primary);
        margin-top: 0.5rem;
    }
    header.nav-open nav {
        display: flex;
    }
    nav a {
        padding: 0.75rem 1rem;
        border-top: 1px solid var(--color-primary-dark);
    }
    header {
        flex-direction: column;
    }
    nav {
        margin-top: 1rem;
    }
    #language-switcher {
        margin-top: 1rem;
    }
}

/* ---------------------------------------------------------------
   Existing custom components (equipment modal, map loader, etc.)
   --------------------------------------------------------------- */
/* Equipment modal – inherits new colors */
#equipment-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
#equipment-modal .modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    max-width: 360px;
    width: 90%;
    padding: 1.5rem 1.2rem;
    box-shadow: var(--shadow);
    position: relative;
}
#equipment-modal label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
#equipment-modal input {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: var(--radius);
}
#equipment-modal button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    padding: 0.45rem 0.9rem;
    margin-right: 0.5rem;
    font-weight: 600;
}
#save-equipment {
    background: #2e7d32;
    color: #fff;
}
#cancel-equipment {
    background: #c62828;
    color: #fff;
}

/* Loading spinner for equipment (uses same keyframes) */
#equipment-spinner {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    align-items: center;
    justify-content: center;
}
#equipment-spinner::after {
    content: "";
    width: 2.2rem;
    height: 2.2rem;
    border: 3px solid #999;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* Map loader – now shares the global loader style */
#map-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary-dark);
    z-index: 1000;
}

/* Highlighted rows from map */
.highlight {
    background-color: #ffff99 !important;
}
