/* Style 5: Professional Gray Theme */

/* Lock page to viewport: no outer page scrollbar */
html {
    height: 100%;
    overflow: hidden;
}

/* basic page background and font */
body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: #2c3e50;
    height: 100%;
    overflow: hidden;
}

:root {
    --side-nav-width: 300px;
    --side-nav-gap: 10px;
}

body.with-side-navbar {
    padding-left: calc(var(--side-nav-width) + var(--side-nav-gap));
    transition: padding-left 0.2s ease;
}

body.with-side-navbar.side-navbar-collapsed {
    padding-left: 0;
}

.side-nav-handle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1085;
    width: 0.9rem;
    height: 4rem;
    background: rgba(46, 67, 87, 0.6);
    border-radius: 0 0.4rem 0.4rem 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: width 0.18s ease, background 0.18s ease;
    touch-action: none;
}
.side-nav-handle:hover,
.side-nav-handle:active {
    width: 1.4rem;
    background: rgba(46, 67, 87, 0.92);
}
.side-nav-handle.side-nav-handle-expanded {
    left: calc(var(--side-nav-width) + 0.5rem);
    width: 0.6rem;
    border-radius: 0 0.25rem 0.25rem 0;
    background: rgba(46, 67, 87, 0.45);
}
.side-nav-handle.side-nav-handle-expanded:hover {
    width: 0.9rem;
    background: rgba(46, 67, 87, 0.75);
}
.side-nav-handle-grip {
    width: 60%;
    height: 0.125rem;
    background: rgba(255,255,255,0.55);
    border-radius: 1px;
}
.side-nav-handle:hover .side-nav-handle-grip,
.side-nav-handle.side-nav-handle-expanded .side-nav-handle-grip {
    background: rgba(255,255,255,0.8);
}

.side-navbar {
    position: fixed;
    top: 8px;
    left: 8px;
    bottom: 8px;
    width: var(--side-nav-width);
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid #233649;
    background: linear-gradient(180deg, #2e4357 0%, #223344 100%);
    color: #f5f8fb;
    box-shadow: 0 12px 28px rgba(23, 38, 53, 0.34);
    transform: translateX(0);
    transition: transform 0.22s ease;
    z-index: 1080;
}

body.side-navbar-collapsed .side-navbar {
    transform: translateX(calc(-100% - 24px));
}

.side-navbar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(208, 224, 236, 0.18);
}

.side-navbar-brand {
    color: #eef4f9;
    text-decoration: none;
    font-size: 0.96rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.side-navbar-brand:hover {
    color: #ffffff;
}

/* Theme brand display */
.app-theme-brand { display: flex; align-items: center; gap: .5rem; }
.app-theme-logo { max-height: 2.2rem; max-width: 6rem; object-fit: contain; }
.app-theme-text { font-weight: 700; letter-spacing: .2px; }
.side-navbar-theme .app-theme-logo { max-height: 1.8rem; filter: brightness(1.1); }
.side-navbar-theme .app-theme-text { color: #f5f8fb; font-size: .82rem; line-height: 1.15; word-break: normal; overflow-wrap: normal; }
.side-navbar-theme .app-theme-brand { display: flex; align-items: center; gap: .3rem; }
.dashboard-theme-wrap .dashboard-theme { margin: 0; }
.dashboard-theme-wrap .app-theme-logo { max-height: 2.2rem; max-width: 8rem; }
.dashboard-theme-wrap .app-theme-text { font-size: 1.1rem; color: #1f3b54; }
.login-theme { justify-content: center; }
.login-theme .app-theme-logo { max-height: 3rem; max-width: 12rem; }
.login-theme .app-theme-text { font-size: 1.3rem; color: #fff; }

.side-navbar-user {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(208, 224, 236, 0.16);
}

.side-navbar-user-name {
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.2;
}

.side-navbar-user-role {
    font-size: 0.74rem;
    color: #c7d5e1;
    margin-top: 2px;
}

.side-navbar-menu {
    flex: 1 1 auto;
    overflow: auto;
    padding: 8px 8px 10px;
}

.side-nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    color: #dce7ef;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 7px 9px;
    font-size: 0.83rem;
    font-weight: 600;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.02);
}

.side-nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
}

.side-nav-link:hover {
    color: #ffffff;
    border-color: rgba(178, 200, 218, 0.34);
    background: rgba(255, 255, 255, 0.08);
}

.side-nav-link.active {
    color: #ffffff;
    border-color: rgba(201, 221, 237, 0.45);
    background: linear-gradient(90deg, rgba(90, 122, 150, 0.55), rgba(54, 82, 106, 0.68));
}

.side-nav-link-admin {
    border-style: dashed;
    border-color: rgba(234, 198, 111, 0.38);
}

.side-nav-divider {
    height: 1px;
    margin: 8px 3px 10px;
    background: linear-gradient(90deg, rgba(170, 191, 208, 0), rgba(170, 191, 208, 0.45), rgba(170, 191, 208, 0));
}

.side-navbar-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(208, 224, 236, 0.16);
}

.side-lang-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

/* subtle shadow on navigation bar to lift it from the background */
.navbar {
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    background: linear-gradient(90deg, #34495e 0%, #2c3e50 100%);
    border: none;
}

.compact-nav {
    min-height: 44px;
    position: relative;
    z-index: 1042;
}

.compact-nav .nav-link,
.compact-nav .navbar-brand {
    padding-top: .35rem;
    padding-bottom: .35rem;
}

.navbar .navbar-brand,
.navbar .nav-link,
.navbar .navbar-text {
    color: #ecf0f1 !important;
}

.navbar .nav-link:hover {
    color: #bdc3c7 !important;
}

.quick-toolbar-wrap {
    background: #dfe6eb;
    border-top: 1px solid #aeb9c3;
    position: sticky;
    top: 0;
    z-index: 1038;
    box-shadow: 0 2px 6px rgba(20, 46, 73, 0.12);
}

.navbar .dropdown,
.navbar .dropdown-menu {
    z-index: 1060;
}

.navbar .dropdown {
    position: relative;
}

.navbar .dropdown-menu {
    position: absolute;
}

.quick-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    padding: .35rem .55rem;
}

.quick-action-btn,
.quick-btn-toggle {
    border: 1px solid #8fa0b0;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.15;
    padding: .26rem .5rem;
    color: #1f3245;
    background: #f6f8fa;
}

.quick-action-btn:hover,
.quick-btn-toggle:hover {
    background: #ffffff;
    border-color: #5f7890;
    color: #102233;
}

/* main content container with card-like appearance */
.container-fluid.main {
    width: 99%;
    max-width: 1920px;
    margin: 0 auto;
    background: #ecf0f1;
    padding: .8rem;
    border-radius: .5rem;
    box-shadow: 0 0.25rem .6rem rgba(0,0,0,.08);
    margin-top: .35rem;
    border: 1px solid #bdc3c7;
    /* Fill viewport height (minus top margin) and scroll internally */
    box-sizing: border-box;
    height: calc(100% - 0.35rem);
    overflow-y: auto;
}

/* Full-screen layouts: content fills container, internal sections scroll */
.container-fluid.main.main-carto,
.container-fluid.main.main-dashboard {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- row layout for hours entry form --- */
.row-entry,
.entry-header {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    margin-bottom: 4px;
    font-size: 1.1rem;
}

.row-entry > div,
.entry-header > div {
    min-width: 0;
    box-sizing: border-box;
    padding: 0 2px;
    flex: 0 0 auto;
}

.row-entry .col-emp,
.entry-header .col-emp { flex: 0 0 14%; }
.row-entry .col-year,
.entry-header .col-year { flex: 0 0 6%; }
.row-entry .col-month,
.entry-header .col-month { flex: 0 0 10%; }
.row-entry .col-type,
.entry-header .col-type { flex: 0 0 24%; }
.row-entry .col-date,
.entry-header .col-date { flex: 0 0 9%; }
.row-entry .col-time,
.entry-header .col-time { flex: 0 0 5%; }
.row-entry .col-hours,
.entry-header .col-hours { flex: 0 0 6%; }
.row-entry .col-desc,
.entry-header .col-desc { flex: 1 1 20%; }
.row-entry .col-btn,
.entry-header .col-btn { flex: 0 0 auto; }

.row-entry .form-control,
.row-entry .form-select {
    width: 100%;
    box-sizing: border-box;
    padding: 2px 6px;
    font-size: 1.1rem;
    border-radius: 0.375rem;
    border: 1px solid #95a5a6;
    background: #ffffff;
    color: #2c3e50;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.row-entry .form-control:focus,
.row-entry .form-select:focus {
    border-color: #34495e;
    box-shadow: 0 0 0 0.2rem rgba(52, 73, 94, 0.25);
}

.entry-header > div {
    padding: 2px 6px;
}

.wrap-row { flex-wrap: wrap; }

#history-table td,
#history-table th {
    padding: 0.15rem 0.4rem;
    vertical-align: middle;
}

#history-table {
    font-size: 0.9rem;
    line-height: 1.2;
}

#history-table thead th {
    background: linear-gradient(90deg, #34495e 0%, #2c3e50 100%);
    color: white;
}

.form-label {
    font-weight: 600;
    color: #2c3e50;
}

.container {
    max-width: none !important;
}

.btn + .btn {
    margin-left: .5rem;
}

.btn {
    font-weight: bold;
}

h2, h3, h4 {
    color: #34495e;
}

.toast-container {
    z-index: 1100;
}

#operator-rows {
    display: none;
}

.minw-350 { min-width: 350px; }
.minw-220 { min-width: 220px; }

.navbar-brand {
    font-weight: 600;
    color: #ecf0f1;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(236, 240, 241, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 30%;
    max-width: 400px;
    margin: 8rem auto 0;
    padding: 2rem 1.5rem;
    background: #ecf0f1;
    border-radius: .5rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.1);
    border: 1px solid #bdc3c7;
    color: #2c3e50;
}

.btn-primary {
    background: #3498db;
    border: none;
    transition: transform 0.2s;
}

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

.btn-success {
    background: #27ae60;
    border: none;
}

.btn-warning {
    background: #f39c12;
    border: none;
}

.btn-danger {
    background: #e74c3c;
    border: none;
}

.btn-outline-primary {
    color: #5dade2;
    border-color: #5dade2;
}

.btn-outline-primary:hover {
    background-color: #5dade2;
    border-color: #5dade2;
}

.navbar .btn-outline-success {
    color: #f7f9fa;
    border-color: #f7f9fa;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar .btn-outline-success:hover,
.navbar .btn-outline-success:focus {
    color: #2c3e50;
    background-color: #f7f9fa;
    border-color: #f7f9fa;
}

.btn-outline-info {
    color: #85c1e9;
    border-color: #85c1e9;
}

.btn-outline-info:hover {
    background-color: #85c1e9;
    border-color: #85c1e9;
}

.btn-outline-warning {
    color: #f1c40f !important;
    border-color: #f1c40f !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
    color: #2c3e50 !important;
    background-color: #f7dc6f !important;
    border-color: #f1c40f !important;
    box-shadow: 0 0.25rem 0.5rem rgba(243, 156, 18, 0.30);
}

.btn-outline-secondary {
    color: #aab7b8;
    border-color: #aab7b8;
}

.btn-outline-secondary:hover {
    background-color: #aab7b8;
    border-color: #aab7b8;
}

.audit-settings-btn {
    color: #f1c40f !important;
    border-color: #f1c40f !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

.audit-settings-btn:hover,
.audit-settings-btn:focus {
    color: #2c3e50 !important;
    background-color: #f7dc6f !important;
    border-color: #f1c40f !important;
    box-shadow: 0 0.25rem 0.5rem rgba(243, 156, 18, 0.30);
}

/* diary-specific extensions */
.panel-card,
.metric-card,
.vocab-card,
.panel {
    border: 1px solid #bdc3c7 !important;
    border-radius: .5rem !important;
    background: #ffffff;
    box-shadow: 0 0.2rem .55rem rgba(0,0,0,.07) !important;
}

.panel-card .card-header,
.metric-card .card-header,
.panel .card-header,
.vocab-card .card-header {
    padding: .5rem .7rem;
}

.panel-card .card-body,
.metric-card .card-body,
.panel .card-body,
.vocab-card .card-body {
    padding: .6rem .7rem;
}

.table {
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: .35rem .45rem;
    font-size: .9rem;
    line-height: 1.2;
    vertical-align: middle;
}

.alert {
    margin-bottom: .6rem;
    padding: .5rem .65rem;
}

.context-menu {
    border: 1px solid #bdc3c7 !important;
    background: #ffffff !important;
}

.context-menu li a {
    color: #2c3e50 !important;
}

#recordingMap {
    border: 1px solid #95a5a6 !important;
}

@media (max-width: 992px) {
    body.with-side-navbar {
        padding-left: 0;
    }

    .side-navbar {
        top: 0;
        left: 0;
        bottom: 0;
        width: min(88vw, 320px);
        border-radius: 0;
    }

    body.side-navbar-collapsed .side-navbar {
        transform: translateX(-100%);
    }

    .side-nav-handle {
        top: 50%;
        left: 0;
        height: 3.25rem;
        width: 0.9rem;
    }

    .login-wrapper {
        width: 92%;
        max-width: 500px;
        margin-top: 4rem;
    }

    .container-fluid.main {
        width: 100%;
        border-radius: 0;
        margin-top: 0;
        height: 100%; /* no top margin on mobile */
    }

    .container-fluid.main.main-dashboard {
        overflow-y: auto; /* allow vertical scroll on mobile */
    }
}

/* ── Phonebook search autocomplete ── */
.phonebook-search-wrapper {
    position: relative;
}

.phonebook-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.12);
    display: none;
}

.phonebook-search-dropdown.show {
    display: block;
}

.phonebook-search-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.12s;
}

.phonebook-search-item:last-child {
    border-bottom: none;
}

.phonebook-search-item:hover,
.phonebook-search-item.active {
    background: #e8f0fe;
}

.phonebook-search-item .ps-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #2c3e50;
}

.phonebook-search-item .ps-org {
    font-size: 0.75rem;
    color: #6c757d;
}

.phonebook-search-item .ps-phone {
    font-size: 0.82rem;
    color: #198754;
    font-weight: 500;
}

.phonebook-search-item .ps-label {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-left: 0.35rem;
}

.phonebook-search-no-results {
    padding: 0.75rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.8rem;
}

.phonebook-search-spinner {
    padding: 0.75rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.8rem;
}
