/* assets/css/style.css */

:root {
    /* Color Palette - Modern Dark Theme */
    --bg-darker: #0d1117;
    --bg-dark: #161b22;
    --bg-card: #21262d;
    --bg-card-hover: #30363d;

    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #484f58;

    --primary-color: #58a6ff;
    --primary-hover: #3182ce;

    --success-color: #2ea043;
    --danger-color: #f85149;
    --warning-color: #d29922;

    --border-color: #30363d;
    --border-radius-sm: 4px;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    /* Shadows & Transitions */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    --transition: all 0.2s ease-in-out;

    /* Typo */
    --font-family: 'Inter', sans-serif;
}

:root[data-theme="light"] {
    /* Color Palette - Light Theme overrides */
    --bg-darker: #f3f4f6;
    --bg-dark: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f9fafb;

    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;

    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;

    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;

    --border-color: #e5e7eb;

    /* Adjusting shadows for light mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-darker);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    /* App takes full screen */
}

/* App Layout Structure */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.hidden {
    display: none !important;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
    width: 260px;
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
}

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

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.user-profile {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #8a2be2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
}

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

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

.nav-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.board-list {
    list-style: none;
}

.board-list li {
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.board-list li:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.board-list li.active {
    background-color: rgba(88, 166, 255, 0.1);
    color: var(--primary-color);
}

/* ---------------- Main Content ---------------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    /* Important for flex children truncating */
    background-color: var(--bg-darker);
    position: relative;
    overflow-y: auto;
}

/* ---------------- Board View ---------------- */
.board-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-dark);
    border-bottom: 1px solid var(--border-color);
}

.board-title-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.board-title-area h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.board-actions {
    display: flex;
    gap: 0.5rem;
}

.board-canvas {
    flex: 1;
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 0;
    align-items: flex-start;
}

/* ---------------- Columns ---------------- */
.column {
    background-color: var(--bg-dark);
    border-radius: var(--border-radius);
    width: 320px;
    min-width: 320px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    transition: opacity 0.2s;
}

.column.is-dragging-column {
    opacity: 0.5;
    background-color: var(--bg-card-hover);
}

.column-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid transparent;
}

.column-title {
    flex: 1;
    cursor: pointer;
}

.column-actions {
    display: flex;
    gap: 0.2rem;
}

.column-body {
    padding: 0.5rem;
    flex: 1;
    overflow-y: auto;
    min-height: 50px;
}

.add-task-btn {
    margin: 0.5rem;
    padding: 0.5rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.add-task-btn:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.add-column-wrapper {
    min-width: 320px;
}

.btn-add-column {
    width: 100%;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.btn-add-column:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ---------------- Tasks (Cards) ---------------- */
.task-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    transition: box-shadow 0.2s, border-color 0.2s;
    position: relative;
}

.task-card:hover {
    border-color: var(--text-muted);
}

.task-card:active {
    cursor: grabbing;
}

.task-card.is-dragging {
    opacity: 0.5;
    background-color: var(--bg-card-hover);
}

.task-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    word-wrap: break-word;
}

.task-arrows {
    display: flex;
    gap: 0.1rem;
    opacity: 1;
}

.arrow-btn {
    padding: 0.2rem 0.3rem;
    font-size: 0.8rem;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.task-assignee {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 12px;
}

/* ---------------- Auth View ---------------- */
.auth-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.auth-card {
    background-color: var(--bg-dark);
    padding: 2.5rem;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

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

.auth-header p {
    color: var(--text-secondary);
}

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

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

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

.auth-form {
    display: none;
}

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

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

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-card-hover);
}

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

.btn-block {
    width: 100%;
    margin-top: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-card-hover);
}

/* ---------------- Autocomplete ---------------- */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-width: 300px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-top: 0.25rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.autocomplete-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

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

.autocomplete-item:hover {
    background: var(--bg-card-hover);
}

/* ---------------- Modals ---------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background-color: var(--bg-dark);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(0);
    transition: transform 0.3s;
}

.modal.hidden {
    display: none;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

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

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

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

.flex-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.flex-1 {
    flex: 1;
}

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

.w-auto {
    width: auto;
}

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-badge {
    background-color: rgba(46, 160, 67, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(46, 160, 67, 0.4);
}

/* ---------------- Toasts ---------------- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s forwards, fadeOut 0.3s 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-error {
    border-left-color: var(--danger-color);
}

.toast-success {
    border-left-color: var(--success-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

/* ---------------- Inbox / Messages ---------------- */
.inbox-sidebar {
    width: 250px;
    flex-shrink: 0;
}

/* ---------------- Responsive & Mobile ---------------- */
.mobile-only {
    display: none;
}

/* Sidebar Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar {
    display: none !important;
}

body.sidebar-collapsed #btn-mobile-sidebar {
    display: inline-block !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    /* Keep the sidebar hidden off-screen as a drawer */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 2000;
        transform: translateX(-100%);
        padding-top: calc(2rem + env(safe-area-inset-top, 0px));
        /* Posun ikonky/názvu pod stavový řádek */
    }

    .sidebar.show-mobile {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    /* Hide the non-board elements inside the hamburger sidebar */
    .sidebar .user-profile,
    .sidebar .sidebar-nav>.nav-section:first-child {
        display: none !important;
    }

    /* App container needs to pad bottom for the mobile tab bar */
    .app-container {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    /* Mobile Bottom Tab Navigation */
    #mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background-color: var(--bg-dark);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
    }

    #mobile-bottom-nav.hidden {
        display: none !important;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        color: var(--text-secondary);
        font-size: 0.7rem;
        cursor: pointer;
        position: relative;
    }

    .mobile-nav-item:hover,
    .mobile-nav-item:active {
        color: var(--primary-color);
    }

    .mobile-nav-item i {
        font-size: 1.25rem;
        margin-bottom: 2px;
    }

    .avatar-small {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary-color), #8a2be2);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    .toast-container {
        bottom: calc(110px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #mobile-inbox-badge,
    #mobile-admin-pending-badge {
        position: absolute;
        top: 4px;
        right: 20%;
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    /* Fixed Top Board Header */
    .board-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 999;
        flex-direction: column;
        align-items: stretch;
        padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
        /* Extra mezera nahoře */
        padding-bottom: 0.75rem;
    }

    .board-title-area {
        justify-content: flex-start;
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .board-title-area h1 {
        font-size: 1.25rem;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .board-actions {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }

    .board-actions .btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    /* Invisible spacer under the fixed header */
    #mobile-top-nav-margin {
        height: calc(120px + env(safe-area-inset-top, 0px));
        flex-shrink: 0;
    }

    /* Adjust Columns for better mobile viewing */
    .board-canvas {
        padding: 1rem;
        padding-bottom: 2rem;
    }

    .column {
        width: 280px;
        min-width: 280px;
    }

    .inbox-sidebar {
        width: 110px;
    }
}