/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Focus */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* App Layout */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-center {
    flex: 1;
    max-width: 400px;
    margin: 0 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--foreground);
}

.logo span {
    color: var(--primary);
}

/* Search */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    transition: all var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.search-box svg {
    color: var(--muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--foreground);
    outline: none;
}

.search-box input::placeholder {
    color: var(--muted);
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1rem 0;
    flex-shrink: 0;
    transition: transform var(--transition-slow), width var(--transition-slow);
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-section {
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

/* Collapsible Sections */
.sidebar-section.collapsible .sidebar-title {
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-sm);
    margin: 0 -0.5rem 0.75rem -0.5rem;
    padding: 0.375rem 0.5rem;
    transition: background var(--transition);
}

.sidebar-section.collapsible .sidebar-title:hover {
    background: var(--surface-hover);
}

.sidebar-section.collapsible .sidebar-title span {
    flex: 1;
}

.sidebar-section.collapsible .collapse-chevron {
    transition: transform var(--transition);
    opacity: 0.5;
}

.sidebar-section.collapsible.collapsed .collapse-chevron {
    transform: rotate(-90deg);
}

.sidebar-section.collapsible .section-content {
    transition: all var(--transition);
    overflow: hidden;
}

.sidebar-section.collapsible.collapsed .section-content {
    display: none;
}

.sidebar-section.collapsible.collapsed {
    margin-bottom: 0.5rem;
}

.sidebar-section.collapsible.collapsed .sidebar-title {
    margin-bottom: 0;
}

/* Project List */
.project-list {
    list-style: none;
}

.project-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.project-item:hover {
    background: var(--surface-hover);
}

.project-item.active {
    background: var(--primary-subtle);
    color: var(--primary);
}

.project-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.project-name {
    flex: 1;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-edit {
    opacity: 0;
    color: var(--muted);
    transition: opacity var(--transition);
}

.project-item:hover .project-edit {
    opacity: 1;
}

.project-edit:hover {
    color: var(--primary);
}

.project-item[draggable="true"] {
    cursor: grab;
}

.project-item[draggable="true"]:active {
    cursor: grabbing;
}

.project-item.dragging {
    background: var(--primary-subtle);
}

/* Due List */
.due-list {
    list-style: none;
}

.due-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition);
    margin-bottom: 0.25rem;
}

.due-item:hover {
    background: var(--surface-hover);
}

.due-item {
    color: var(--foreground);
}

.due-item.overdue span:first-child {
    color: var(--foreground);
}

.due-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    background: var(--warning-subtle);
    color: var(--warning);
}

.due-item.overdue .due-badge {
    background: var(--error-subtle);
    color: var(--error);
}

/* Pinned Cards List */
.pinned-cards-list {
    list-style: none;
}

.pinned-card-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 0.25rem;
}

.pinned-card-item:hover {
    background: var(--surface-hover);
}

.pinned-card-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pinned-card-title {
    flex: 1;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tag List */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tag-item:hover {
    filter: brightness(0.9);
}

/* Add Project Button */
.btn-add-project {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 0.5rem;
}

.btn-add-project:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

/* Board */
.board-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.board {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    justify-content: center;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--muted);
    padding: 2rem;
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.empty-state.hidden {
    display: none;
}

.empty-state-projects {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    max-width: 500px;
}

.empty-state-project {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--foreground);
    cursor: pointer;
    transition: all var(--transition);
}

.empty-state-project:hover {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.empty-state-project .project-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Columns Container */
.columns-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-items: center;
}

.columns-container.hidden {
    display: none;
}

/* Inline Board Title */
.board-title-inline {
    text-align: center;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

.board-title-inline h2 {
    font-size: 2.75rem;
    font-weight: 600;
    color: var(--foreground);
}

.board-title-inline p {
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* Columns Wrapper */
.columns-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
}

/* Add Column Button */
.add-column-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 48px;
    padding: 0.75rem 0.5rem;
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--muted);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.add-column-btn span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.add-column-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .header-left {
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .header-center {
        flex: 1;
        margin: 0 0.5rem;
        max-width: none;
    }

    .search-box {
        padding: 0.375rem 0.625rem;
    }

    .search-box input {
        font-size: 0.8125rem;
        min-width: 0;
    }

    .header-right {
        gap: 0.25rem;
    }

    .header-right .btn-icon {
        width: 32px;
        height: 32px;
    }

    .sidebar {
        position: absolute;
        left: 0;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        z-index: 50;
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .hide-mobile {
        display: none;
    }

    /* Board auf Mobile */
    .board {
        padding: 1rem;
    }

    .board-title-inline {
        margin-bottom: 1rem;
    }

    .board-title-inline h2 {
        font-size: 1.25rem;
    }

    .columns-wrapper {
        gap: 0.75rem;
    }

    .column {
        flex: 0 0 300px;
        min-width: 300px;
    }

    .add-column-btn {
        width: 40px;
    }

    /* Modal auf Mobile */
    .modal {
        max-width: calc(100vw - 2rem);
        max-height: calc(100vh - 2rem);
    }

    .quick-add {
        max-width: calc(100vw - 2rem);
    }
}

/* Sehr kleine Screens */
@media (max-width: 480px) {
    .header-center {
        display: none;
    }

    .header-right .btn:not(.btn-icon) {
        padding: 0.375rem;
    }

    .header-right .btn:not(.btn-icon) span {
        display: none;
    }
}

/* Mobile: Spalten untereinander */
@media (max-width: 600px) {
    .board {
        justify-content: flex-start;
        align-items: flex-start;
        padding: 1rem;
    }

    .columns-container {
        width: 100%;
        align-items: flex-start;
    }

    .board-title-inline {
        text-align: left;
        width: 100%;
    }

    .columns-wrapper {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 2rem;
    }

    .column {
        flex: none;
        width: 100%;
        max-height: none;
    }

    .column-body {
        max-height: 300px;
        overflow-y: auto;
    }

    /* Collapsed Spalten horizontal */
    .column.collapsed {
        flex: none;
        width: 100%;
        min-width: 100%;
        height: auto;
    }

    .column.collapsed .column-header {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
        height: auto;
        border-bottom: 1px solid var(--border);
    }

    .column.collapsed .column-header,
    .column.collapsed .column-header * {
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
    }

    .column.collapsed .column-title {
        flex-direction: row;
        font-size: 1rem !important;
    }

    /* Add Column Button horizontal */
    .add-column-btn {
        flex-direction: row;
        width: 100%;
        min-height: auto;
        padding: 0.75rem 1rem;
    }

    .add-column-btn span {
        writing-mode: horizontal-tb;
        text-orientation: mixed;
    }
}
