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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f1a;
    --accent: #722f37;
    --accent-hover: #8b3a42;
    --accent-light: #a04550;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --border-color: #2a2a4a;
    --success: #61bd4f;
    --danger: #eb5a46;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --radius-small: 4px;
    --transition: 150ms ease;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Typography */
h1, h2, h3 {
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

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

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

.btn-primary:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
}

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

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

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

.btn-danger:hover {
    background: #d14836;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

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

textarea {
    resize: vertical;
    min-height: 100px;
}

select {
    cursor: pointer;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-title {
    text-align: center;
    margin-bottom: 32px;
    font-size: 28px;
    color: var(--accent-light);
}

.error-message {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
    min-height: 20px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
}

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

.logo {
    font-size: 20px;
    color: var(--accent-light);
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--transition);
}

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

.app-version {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 8px;
    opacity: 0.7;
}

.header-separator {
    color: var(--text-secondary);
    font-size: 18px;
    margin: 0 8px;
}

.header-board-name {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

.header-board-name:hover {
    color: var(--accent-light);
}

.header-board-name-input {
    font-size: 18px;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: var(--radius-small);
}

.board-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.board-selector select {
    width: 200px;
}

.search-container {
    position: relative;
}

.search-container input {
    width: 250px;
    padding-left: 12px;
}

.search-container input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#username-display {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    height: calc(100vh - 57px);
    overflow-x: auto;
    padding: 20px;
}

/* Homepage */
.homepage-container {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.homepage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.board-card {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    min-height: 100px;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 500;
    font-size: 16px;
    border: 2px solid transparent;
}

.board-card:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.board-card-add {
    background: transparent;
    border: 2px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 32px;
}

.board-card-add:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: transparent;
}

.board-card-menu {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity var(--transition);
}

.board-card:hover .board-card-menu {
    opacity: 1;
}

.board-card-menu-btn {
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-card-menu-btn:hover {
    background: rgba(0, 0, 0, 0.5);
}

.board-card-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-small);
    min-width: 120px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.board-card-dropdown.show {
    display: block;
}

.board-card-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.board-card-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.board-card-dropdown-item.danger {
    color: var(--danger);
}

.board-card-name {
    width: 100%;
}

.board-card-name-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-small);
    font-size: 16px;
    font-weight: 500;
    text-align: center;
}

.board-container {
    display: flex;
    gap: 16px;
    height: 100%;
    align-items: flex-start;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 300px;
    color: var(--text-secondary);
    font-size: 16px;
}

/* Lists */
.list {
    flex-shrink: 0;
    width: 280px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
}

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

.list-title {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    color: var(--text-primary);
    padding: 4px 6px;
    border-radius: var(--radius-small);
    cursor: pointer;
}

.list-title:hover {
    background: var(--bg-tertiary);
}

.list-title-input {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 4px 6px;
    border-radius: var(--radius-small);
    outline: none;
}

.list-menu {
    position: relative;
}

.list-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    border-radius: var(--radius-small);
}

.list-menu-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.list-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 4px;
    min-width: 120px;
    z-index: 100;
    display: none;
}

.list-menu-dropdown.show {
    display: block;
}

.list-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-small);
}

.list-menu-item:hover {
    background: var(--border-color);
}

.list-menu-item.danger {
    color: var(--danger);
}

.list-cards {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 50px;
}

.list-cards.drag-over {
    background: rgba(114, 47, 55, 0.1);
}

.list-footer {
    padding: 8px;
    border-top: 1px solid var(--border-color);
}

.add-card-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-small);
    transition: background var(--transition);
}

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

/* Add List */
.add-list {
    flex-shrink: 0;
    width: 280px;
}

.add-list-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.add-list-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent);
    color: var(--text-primary);
}

.add-list-form {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius);
}

.add-list-form input {
    margin-bottom: 8px;
}

.add-list-actions {
    display: flex;
    gap: 8px;
}

/* Cards */
.card {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid transparent;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-color);
}

.card.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
}

.card.drag-preview {
    background: var(--accent);
    opacity: 0.8;
}

.card-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.card-label {
    min-width: 40px;
    height: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.card-label.expanded {
    height: auto;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #1a1a1a;
    min-width: auto;
}

.card-title {
    font-size: 14px;
    word-break: break-word;
}

.card-description-preview {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

/* Highlighted card (search result) */
.card.highlighted {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(114, 47, 55, 0.3);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.modal-small {
    max-width: 350px;
}

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

.modal-header h3 {
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    gap: 12px;
}

.card-title-input {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0;
}

.card-title-input:focus {
    outline: none;
}

/* Labels Selector */
.labels-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.label-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
    position: relative;
}

.label-option:hover {
    opacity: 0.85;
}

.label-option.selected {
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.4), 0 0 0 2px var(--accent);
}

.label-option .label-name {
    font-size: 13px;
    color: #1a1a1a;
    font-weight: 600;
}

/* Settings */
.settings-labels {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-label-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-label-color {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-small);
    flex-shrink: 0;
}

.settings-label-input {
    flex: 1;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
    }

    .header-left,
    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .board-selector select {
        width: 150px;
    }

    .search-container input {
        width: 150px;
    }

    .list {
        width: 260px;
    }
}
