/* ================================================================
   Kinetix — Custom Styles
   Bootstrap 5 base + custom variables + component overrides
   ================================================================ */

/* ---------------------------------------------------------------
   CSS Variables / Theme
   --------------------------------------------------------------- */
:root {
    --kx-primary:        #2563eb;   /* blue-600 */
    --kx-primary-dark:   #1d4ed8;   /* blue-700 */
    --kx-surface:        #f8fafc;
    --kx-surface-card:   #ffffff;
    --kx-border:         #e2e8f0;
    --kx-text:           #1e293b;
    --kx-text-muted:     #64748b;
    --kx-nav-bg:         #0f172a;   /* slate-900 */
    --kx-nav-height:     58px;
    --kx-radius:         0.5rem;
    --kx-shadow:         0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --kx-shadow-md:      0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* ---------------------------------------------------------------
   Base
   --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--kx-surface);
    color: var(--kx-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9375rem;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--kx-primary); text-decoration: none; }
a:hover { color: var(--kx-primary-dark); text-decoration: underline; }

/* ---------------------------------------------------------------
   Navbar
   --------------------------------------------------------------- */
.kx-navbar {
    background: var(--kx-nav-bg) !important;
    height: var(--kx-nav-height);
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.kx-navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.15rem;
    letter-spacing: 0.03em;
    color: #fff !important;
}

.kx-brand-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 2px;
}

.kx-navbar .nav-link {
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--kx-radius);
    transition: background 0.15s;
}

.kx-navbar .nav-link:hover,
.kx-navbar .nav-link.active {
    background: rgb(255 255 255 / 0.08);
}

.kx-role-badge {
    background: var(--kx-primary);
    color: #fff;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    padding: 0.3em 0.65em;
    border-radius: 999px;
}

/* ---------------------------------------------------------------
   Main / Layout
   --------------------------------------------------------------- */
main.container-fluid {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
}

.kx-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--kx-border);
}

.kx-page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: var(--kx-text);
}

/* ---------------------------------------------------------------
   Cards
   --------------------------------------------------------------- */
.kx-card {
    background: var(--kx-surface-card);
    border: 1px solid var(--kx-border);
    border-radius: var(--kx-radius);
    box-shadow: var(--kx-shadow);
    padding: 1.5rem;
}

.kx-video-card {
    background: linear-gradient(135deg, #fff 0%, #eff6ff 100%);
    border-color: #bfdbfe;
}

.kx-video-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.kx-video-eyebrow {
    color: var(--kx-primary-dark);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.kx-video-panel {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: 860px;
    overflow: hidden;
    border-radius: calc(var(--kx-radius) + 0.1rem);
    background: #020617;
    box-shadow: var(--kx-shadow-md);
}

.kx-video-panel iframe,
.kx-video-panel video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #000;
}

/* ---------------------------------------------------------------
   Tables
   --------------------------------------------------------------- */
.kx-table-wrap {
    background: var(--kx-surface-card);
    border: 1px solid var(--kx-border);
    border-radius: var(--kx-radius);
    box-shadow: var(--kx-shadow);
    overflow: hidden;
}

.kx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.kx-table thead th {
    background: var(--kx-nav-bg);
    color: #cbd5e1;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.kx-table thead th:hover {
    background: #1e293b;
}

.kx-table thead th .sort-icon {
    margin-left: 0.3rem;
    opacity: 0.5;
    font-size: 0.75rem;
}

.kx-table thead th.sorted .sort-icon { opacity: 1; }

.kx-table tbody tr {
    border-bottom: 1px solid var(--kx-border);
    transition: background 0.1s;
}

.kx-table tbody tr:last-child { border-bottom: none; }
.kx-table tbody tr:hover { background: #f1f5f9; }

.kx-table tbody td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
    color: var(--kx-text);
}

.kx-table .td-actions { white-space: nowrap; text-align: right; }

/* Status / date badges */
.kx-date {
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.kx-date.overdue { color: #dc2626; font-weight: 600; }
.kx-date.soon    { color: #d97706; }
.kx-date.ok      { color: #16a34a; }

/* ---------------------------------------------------------------
   Forms
   --------------------------------------------------------------- */
.kx-form label {
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--kx-text);
    margin-bottom: 0.3rem;
}

.kx-form .form-control,
.kx-form .form-select {
    border-color: var(--kx-border);
    border-radius: var(--kx-radius);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.kx-form .form-control:focus,
.kx-form .form-select:focus {
    border-color: var(--kx-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */
.btn-kx-primary {
    background: var(--kx-primary);
    border: none;
    color: #fff;
    border-radius: var(--kx-radius);
    padding: 0.42rem 1rem;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s;
    cursor: pointer;
}

.btn-kx-primary:hover { background: var(--kx-primary-dark); color: #fff; }

.btn-sm-icon {
    padding: 0.25rem 0.45rem;
    font-size: 0.8rem;
    border-radius: var(--kx-radius);
    line-height: 1;
}

/* ---------------------------------------------------------------
   Login page
   --------------------------------------------------------------- */
.kx-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.kx-login-box {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: calc(var(--kx-radius) * 2);
    box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
    padding: 2.5rem;
}

.kx-login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.kx-login-logo .kx-login-logo-img {
    width: 78px;
    height: 78px;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: var(--kx-shadow);
    background: #fff;
    padding: 6px;
    margin-bottom: 0.6rem;
}

.kx-login-logo h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: var(--kx-nav-bg);
}

.kx-login-logo p {
    font-size: 0.85rem;
    color: var(--kx-text-muted);
    margin: 0.2rem 0 0;
}

/* ---------------------------------------------------------------
   Screenshots / Gallery
   --------------------------------------------------------------- */
.kx-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.kx-gallery-item {
    position: relative;
    border-radius: var(--kx-radius);
    overflow: hidden;
    border: 1px solid var(--kx-border);
    aspect-ratio: 16/9;
    background: #f1f5f9;
    cursor: pointer;
}

.kx-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.kx-gallery-item:hover img { transform: scale(1.05); }

.kx-gallery-item .kx-gallery-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgb(220 38 38 / 0.85);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

.kx-gallery-item:hover .kx-gallery-del { opacity: 1; }

/* Lightbox overlay */
#kx-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

#kx-lightbox.open { display: flex; }

#kx-lightbox img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: var(--kx-radius);
    box-shadow: 0 25px 60px rgb(0 0 0 / 0.5);
    object-fit: contain;
}

#kx-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

#kx-lightbox-close:hover { opacity: 1; }

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */
.kx-footer {
    background: var(--kx-nav-bg);
    color: #64748b;
    font-size: 0.82rem;
    margin-top: auto;
}

/* ---------------------------------------------------------------
   Utility
   --------------------------------------------------------------- */
.text-muted-sm { font-size: 0.82rem; color: var(--kx-text-muted); }
.fw-medium { font-weight: 500; }

.kx-page-header-projects {
    flex-wrap: nowrap;
}

.kx-page-header-projects h1 {
    white-space: nowrap;
    margin-right: 1rem;
}

.kx-projects-toolbar {
    margin-left: auto;
    flex-wrap: nowrap;
}

.kx-projects-toolbar .form-control,
.kx-projects-toolbar .form-select,
.kx-projects-toolbar .btn {
    white-space: nowrap;
}

.kx-chat-message-short,
.kx-chat-message-full {
    white-space: pre-wrap;
}

.kx-attachment-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}


@media (max-width: 767.98px) {
    .kx-video-card {
        padding: 1rem;
    }

    .kx-video-panel {
        aspect-ratio: 4 / 3;
    }
}
.kx-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--kx-radius);
    padding: 1rem;
    background: #f8fafc;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.kx-dropzone:hover,
.kx-dropzone.is-dragover {
    border-color: var(--kx-primary);
    background: #eff6ff;
}

.kx-rich-editor {
    border: 1px solid var(--kx-border);
    border-radius: var(--kx-radius);
    background: #fff;
}

.kx-rich-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.45rem;
    border-bottom: 1px solid var(--kx-border);
    background: #f8fafc;
}

.kx-rich-input {
    min-height: 160px;
    border: 0 !important;
    box-shadow: none !important;
}

.kx-rich-input:empty::before {
    content: attr(data-placeholder);
    color: var(--kx-text-muted);
}

.kx-rich-text p:last-child,
.kx-rich-text ul:last-child,
.kx-rich-text ol:last-child,
.kx-rich-text blockquote:last-child,
.kx-rich-text pre:last-child {
    margin-bottom: 0;
}

.kx-message-edit {
    border-top: 1px dashed #cbd5e1;
    padding-top: 0.75rem;
}

.kx-message-history {
    border-top: 1px dashed #cbd5e1;
    padding-top: 0.6rem;
}

.kx-message-history-item {
    background: #fff;
    border: 1px solid var(--kx-border);
    border-radius: var(--kx-radius);
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.5rem;
}

.kx-message-history-item:last-child {
    margin-bottom: 0;
}

.kx-attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--kx-border);
    border-radius: var(--kx-radius);
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
}

.kx-attachment-thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--kx-border);
    background: #fff;
}

/* ---------------------------------------------------------------
   Dashboard additions
   --------------------------------------------------------------- */
.kx-project-thumb {
    width: 54px;
    height: 54px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--kx-border);
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.kx-finished-row td {
    opacity: 0.55;
}
.kx-finished-row td a {
    text-decoration: line-through;
    color: var(--kx-muted);
}

/* Navbar badge */
.kx-nav-badge {
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 10px;
    background: #dc3545;
    color: #fff;
    vertical-align: middle;
    margin-left: 3px;
    line-height: 1;
}

.kx-mobile-menu-modal {
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid rgb(255 255 255 / 0.15);
}

.kx-mobile-menu-list .list-group-item {
    background: transparent;
    color: #e2e8f0;
    border-color: rgb(255 255 255 / 0.1);
    font-weight: 500;
}

.kx-mobile-menu-list .list-group-item:hover,
.kx-mobile-menu-list .list-group-item:focus,
.kx-mobile-menu-list .list-group-item.active {
    background: rgb(37 99 235 / 0.22);
    color: #fff;
}

/* Mobile navbar collapse visibility fix */
@media (max-width: 991.98px) {
    .kx-navbar {
        height: auto;
        min-height: var(--kx-nav-height);
        padding: 0.45rem 0.85rem;
        z-index: 2000;
    }

    .kx-navbar .container-fluid {
        position: relative;
    }

    .kx-navbar .navbar-collapse {
        position: absolute;
        top: calc(100% + 2px);
        left: 0;
        right: 0;
        z-index: 2010;
        margin-top: 0;
        padding: 0.5rem 0.7rem 0.8rem;
        border-top: 1px solid rgb(255 255 255 / 0.12);
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
        background: var(--kx-nav-bg);
        box-shadow: 0 12px 24px rgb(0 0 0 / 0.32);
    }

    .kx-navbar .navbar-nav {
        gap: 0.15rem;
    }

    .kx-navbar .nav-link {
        display: block;
        padding: 0.55rem 0.7rem;
    }
}

#projectsCalendar {
    background: #fff;
}

#projectsCalendar .fc-toolbar-title {
    font-size: 1rem;
    font-weight: 700;
}

#projectsCalendar .fc-button {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

#projectsCalendar .fc-button:not(:disabled):hover {
    background: #1e40af;
    border-color: #1e40af;
}

@media (max-width: 992px) {
    .kx-page-header-projects {
        flex-wrap: wrap;
    }

    .kx-projects-toolbar {
        width: 100%;
        flex-wrap: wrap;
        margin-left: 0;
    }

    .kx-projects-toolbar input[data-table-search="projectsTable"] {
        width: 100% !important;
        min-width: 0 !important;
    }

    .kx-attachment-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
