@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.css');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.user-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 20px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-section:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    color: white;
    font-weight: 600;
    font-size: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.user-info h2 {
    color: white;
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.user-info p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    margin: 0;
}

.logo {
    color: white;
    font-size: 1.75rem;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
    letter-spacing: -0.02em;
}

.boards-section {
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    margin-top: -15px; /* Pull up to align better with workspace section */
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.action-button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-button:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sync-button {
    min-width: 120px;
    position: relative;
}

.sync-button.syncing i {
    animation: syncRotate 1s linear infinite;
}

@keyframes syncRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sync-button.success {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
}

.sync-button.error {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2) !important;
}

.sync-info {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.8rem;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hash-button {
    min-width: 130px;
}

.hash-button.has-id {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.hash-button.has-id:hover {
    background: rgba(16, 185, 129, 0.3);
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.2);
}

.sync-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

.sync-button:disabled:hover {
    transform: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

#currentHashDisplay {
    font-weight: 700;
    text-transform: uppercase;
    font-family: 'Monaco', 'Consolas', monospace;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.hidden {
    display: none;
}

.section-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.02em;
}

.boards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.board-card {
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.board-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.board-card.create-new {
    border: 2px dashed rgba(255, 255, 255, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    background: rgba(255, 255, 255, 0.1);
}

.board-card.create-new:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
}

.create-icon {
    font-size: 2.5rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 12px;
    transition: transform 0.2s ease;
}

.board-card.create-new:hover .create-icon {
    transform: scale(1.1);
}

.create-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.board-title {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
    letter-spacing: -0.01em;
    /* Prevent super long titles from breaking the card */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* show max 2 lines */
    line-clamp: 2; /* standard draft property */
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word; /* break long unspaced strings */
    hyphens: auto;
}

.board-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 15px;
    min-height: 40px;
}

/* Board card assignees (aggregated) */
.board-assignees {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.board-assignees .assignee-chip {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(6px);
}

.board-assignees .assignee-chip.more-chip {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
}

.board-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 500;
}

.board-date {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
}

.board-actions {
    display: flex;
    gap: 8px;
}

/* Use Bootstrap buttons; just tweak for glassy background */
.board-actions .btn {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-padding-x: 0.5rem;
    --bs-btn-font-size: 0.8rem;
    backdrop-filter: blur(6px);
}

.board-actions .btn-outline-light:hover {
    background: rgba(255,255,255,0.2);
}

/* New bottom-right floating actions */
.board-card-actions {
    position: absolute;
    right: 14px;
    bottom: 12px;
    display: flex;
    gap: 10px;
    opacity: 0;
    transform: translateY(6px);
    transition: all 0.25s ease;
    pointer-events: none; /* prevent hover flicker until visible */
}

.board-card:hover .board-card-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.board-card-action-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.board-card-action-btn:hover,
.board-card-action-btn:focus {
    background: rgba(255, 255, 255, 0.32);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

.board-card-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.board-card-action-btn.edit {
    /* subtle accent */
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.board-card-action-btn.delete {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.board-card-action-btn.delete:hover { background: rgba(239, 68, 68, 0.45); }
.board-card-action-btn.edit:hover { background: rgba(102, 126, 234, 0.45); }

/* Always show actions on touch devices (no hover) */
@media (pointer: coarse) {
    .board-card-actions { opacity: 1; transform: none; pointer-events: auto; }
}

/* Custom Modal Enhancements */
.modal-backdrop.show {
    opacity: 0.6;
}

/* Break long unspaced board names inside confirmation modal */
#confirmModalMessage .board-title-inline {
    display: inline-block;
    max-width: 100%;
    word-break: break-all; /* ensures super long continuous strings wrap */
    overflow-wrap: anywhere;
    background: rgba(102, 126, 234, 0.15);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    color: #333;
}

#confirmModalMessage .board-title-inline.truncated::after {
    content: '…';
}

/* Override Bootstrap modal content for custom styling */
#hashModal .modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

/* Custom modal header styling */
#hashModal .modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

/* Custom form styling that enhances Bootstrap */
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Custom button colors that match our theme */
.btn-primary {
    background: #667eea;
    border-color: #667eea;
}

.btn-primary:hover, .btn-primary:focus {
    background: #5a6fd8;
    border-color: #5a6fd8;
}

.btn-danger {
    background: #ff4757;
    border-color: #ff4757;
}

.btn-danger:hover, .btn-danger:focus {
    background: #ff3838;
    border-color: #ff3838;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
}

.empty-state h3 {
    font-size: 1.8rem;
    margin-bottom: 16px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    max-width: 400px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.empty-state-icon {
    font-size: 3.5rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
}

.empty-state-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.empty-state-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    color: white;
}

/* Color Picker Styles */
.color-picker-grid {
    /* Center the swatches block under the label */
    display: grid;
    grid-template-columns: repeat(3, 60px); /* match .color-option size */
    /* More harmonic spacing between swatches */
    gap: 15px 100px; /* row-gap, column-gap */
    width: fit-content; /* shrink to content width */
    margin: 10px auto 0; /* center horizontally */
    justify-content: center;
    justify-items: center; /* center items within each cell */
    /* Add side padding so the grid has breathing room within the modal */
    padding: 0 16px;
}

.color-option {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.color-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.color-option.selected {
    border-color: #333;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Custom styles for hash modal */
.letter-spacing-wide {
    letter-spacing: 2px;
}

.font-monospace {
    font-family: 'Monaco', 'Consolas', monospace !important;
}

/* Animation for modal content */
.modal.fade .modal-dialog {
    transform: translate(0, -50px);
    transition: all 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: none;
}

/* Hover effects for cards */
.card:hover {
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

/* Custom input focus styles */
.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Toast positioning */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* Assignee filter select */
.assignee-filter select.form-select {
    color: #fff;
    border-color: rgba(255,255,255,0.5);
    background-color: rgba(255,255,255,0.1);
}

.assignee-filter select.form-select option {
    color: #000;
}

/* Ensure dropdown aligns nicely in the header */
.dropdown .dropdown-menu {
    border-radius: 12px;
}

@media (max-width: 768px) {
    body {
        padding: 15px;
        overscroll-behavior-y: contain;
    }
    
    .header {
        flex-direction: column;
        gap: 24px;
        text-align: center;
        margin-bottom: 32px;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .user-section {
        padding: 16px 24px;
        border-radius: 20px;
        max-width: 300px;
        margin: 0 auto;
        transition: all 0.2s ease;
    }
    
    .user-section:active {
        transform: scale(0.98);
    }
    
    .user-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
        border-radius: 16px;
    }
    
    .user-info h2 {
        font-size: 1.3rem;
    }
    
    .user-info p {
        font-size: 0.85rem;
    }
    
    .boards-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .section-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
        margin-bottom: 24px;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: 12px;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .action-button {
        justify-content: center;
        min-height: 48px;
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 14px;
        transition: all 0.2s ease;
        width: 100%;
    }
    
    .action-button:active {
        transform: scale(0.98);
    }
    
    .board-card {
        border-radius: 20px;
        padding: 24px;
        transition: all 0.2s ease;
        touch-action: manipulation;
    }
    
    .board-card:active {
        transform: scale(0.98);
    }
    
    .board-title {
        font-size: 1.25rem;
        margin-bottom: 12px;
    }
    
    .board-description {
        font-size: 0.9rem;
        line-height: 1.4;
        margin-bottom: 16px;
    }
    
    .board-meta {
        gap: 8px;
    }
    
    .board-actions {
        gap: 8px;
        margin-top: 16px;
    }
    
    .board-action-btn {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 0.9rem;
        border-radius: 12px;
        transition: all 0.2s ease;
    }
    
    .board-action-btn:active {
        transform: scale(0.95);
    }
    
    .create-board-card {
        border-radius: 20px;
        padding: 32px 24px;
        min-height: 200px;
        transition: all 0.2s ease;
    }
    
    .create-board-card:active {
        transform: scale(0.98);
    }
    
    .create-board-icon {
        font-size: 2.5rem;
        margin-bottom: 16px;
    }
    
    .create-board-text {
        font-size: 1.1rem;
    }

    .color-picker-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        max-width: 240px;
        margin: 0 auto;
        padding: 0;
    }
    
    .color-option {
        height: 60px;
        border-radius: 16px;
        transition: all 0.2s ease;
    }
    
    .color-option:active {
        transform: scale(0.95);
    }

    /* Enhanced mobile modal improvements */
    .modal-dialog {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }
    
    .modal-header {
        padding: 24px 20px 20px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
    }
    
    .modal-title {
        font-size: 1.25rem;
        font-weight: 600;
    }
    
    .modal-body {
        padding: 24px 20px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        padding: 20px;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        position: sticky;
        bottom: 0;
        background: white;
        flex-direction: column;
        gap: 12px;
    }

    .modal-footer .btn {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
        border-radius: 12px;
        margin-bottom: 0;
    }
    
    .form-control {
        min-height: 48px;
        font-size: 1rem;
        border-radius: 12px;
        padding: 14px 16px;
    }
    
    .form-select {
        min-height: 48px;
        font-size: 1rem;
        border-radius: 12px;
        padding: 14px 16px;
    }
    
    textarea.form-control {
        min-height: 120px;
        resize: vertical;
    }
    
    .btn-close {
        font-size: 1.2rem;
        padding: 8px;
        margin: -8px;
    }
    
    /* Safe area handling */
    .header {
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    .modal-content {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    /* Pull-to-refresh indicator */
    .pull-to-refresh {
        position: fixed;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(255, 255, 255, 0.9);
        padding: 8px 16px;
        border-radius: 0 0 12px 12px;
        font-size: 0.9rem;
        z-index: 1000;
        transition: transform 0.2s ease;
        backdrop-filter: blur(10px);
    }
    
    .pull-to-refresh.hidden {
        transform: translateX(-50%) translateY(-100%);
    }
    
    /* Haptic feedback simulation */
    @keyframes haptic-light {
        0% { transform: scale(1); }
        50% { transform: scale(1.02); }
        100% { transform: scale(1); }
    }
    
    .haptic-feedback {
        animation: haptic-light 0.1s ease;
    }
}