@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #f7f9fb;
    --bg-sidebar: #f8fafc;
    --bg-hover: #e2e8f0;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --primary: #0f172a;
    --primary-light: rgba(15, 23, 42, 0.08);
    --primary-hover: #000000;
    --secondary: #3b82f6;
    --secondary-light: rgba(59, 130, 246, 0.1);
    
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.1);
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 18px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 18px 36px rgba(15, 23, 42, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --content-padding: 48px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

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

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    overflow: hidden;
}

.brand-section {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    padding: 0 2px;
    order: 1;
}

.brand-logo-image {
    display: block;
    width: 100%;
    max-width: 220px;
    height: 46px;
    object-fit: contain;
    object-position: left center;
}

.brand-logo-circle {
    width: 38px;
    height: 38px;
    background-color: var(--primary);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    flex-shrink: 0;
}

.brand-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.brand-title-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.brand-subtitle-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* Project Selector */
.project-selector {
    position: relative;
    margin-bottom: 22px;
    order: 2;
    padding: 0 4px;
}

.sidebar-project-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 8px;
    padding-left: 2px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.selector-button {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: left;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.2s ease;
    color: var(--primary);
}

.selector-button:hover {
    border-color: #cbd5e1;
    background-color: var(--bg-main);
}

.project-selector-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.project-selector-icon-wrap {
    width: 22px;
    height: 22px;
    background-color: #eef6ff;
    color: var(--secondary);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.project-selector-title span[data-current-project] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.selector-arrow {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
}

/* Project Selector Dropdown */
.project-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.project-dropdown.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.project-search-box {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.project-search-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}

.project-search-input:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.project-dropdown-scroll {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.project-dropdown-link {
    display: block;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
}

.project-dropdown-link:hover {
    background: var(--bg-hover);
}

.dropdown-item {
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
    color: var(--text-main);
}

.dropdown-item:hover {
    background-color: var(--bg-hover);
}

.dropdown-item.selected {
    color: var(--text-main);
    background-color: var(--bg-hover);
    font-weight: 600;
}

/* Nav Menu */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    order: 3;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    margin-right: -4px;
    margin-bottom: 12px;
}

.nav-menu::-webkit-scrollbar {
    width: 5px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 9999px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-section-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin: 8px 10px 6px;
    padding: 0 4px;
    text-transform: uppercase;
}

.nav-item {
    position: relative;
    list-style: none;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.nav-item a:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active a {
    background-color: var(--bg-hover) !important;
    color: var(--text-main) !important;
    font-weight: 600;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background-color: var(--secondary);
    border-radius: 0 9999px 9999px 0;
    z-index: 5;
}

.nav-item i.nav-icon {
    font-size: 15px;
    width: 18px;
    text-align: center;
    color: currentColor;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background-color: var(--danger);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 9999px;
    line-height: 1;
}

.sidebar-project-shortcuts {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 2px 0 8px 42px;
}

.sidebar-project-shortcut,
.sidebar-project-all-link {
    width: 100%;
    min-height: 30px;
    border: 0;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: block;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;
    overflow: hidden;
    padding: 7px 10px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.sidebar-project-shortcut:hover,
.sidebar-project-all-link:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.sidebar-project-shortcut.active {
    background: #ffffff;
    color: var(--text-main);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--secondary);
}

.sidebar-project-all-link {
    color: var(--text-main);
    font-weight: 600;
}

/* Sidebar Footer User Profile */
.user-profile-section {
    border-top: 0;
    padding: 8px 4px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    order: 5;
    margin-top: 4px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.35;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn-icon {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.logout-btn-icon:hover {
    color: var(--danger);
    background-color: var(--danger-light);
}

.sidebar-support-nav {
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 12px -4px 0;
    padding: 12px 4px 0;
    order: 4;
}

.sidebar-support-nav[hidden] {
    display: none;
}

.sidebar-support-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.sidebar-support-nav a:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.sidebar-support-nav a.active {
    background-color: var(--secondary-light) !important;
    color: var(--secondary) !important;
}

/* Hide text links for row display */
.sidebar-support-nav a span:not(.nav-badge) {
    display: none;
}

.sidebar-support-nav i.nav-icon {
    font-size: 16px;
    margin: 0;
    padding: 0;
    width: auto;
    text-align: center;
    color: currentColor;
    flex-shrink: 0;
}

/* Custom CSS Tooltip on Hover */
.sidebar-support-nav a::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background-color: #1e293b;
    color: #ffffff;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-md);
    z-index: 200;
}

.sidebar-support-nav a::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border-width: 4px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s ease;
    z-index: 200;
}

.sidebar-support-nav a:hover::after,
.sidebar-support-nav a:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Absolute top-right badge overlay */
.sidebar-support-nav a .nav-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    margin: 0;
    padding: 0;
    font-size: 9px;
    font-weight: 700;
    background-color: var(--danger);
    color: #ffffff;
    min-width: 14px;
    height: 14px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #ffffff;
    box-sizing: content-box;
    line-height: 1;
}

/* Main Content Styling */
.main-content {
    flex: 0 0 calc(100% - var(--sidebar-width));
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 0 var(--content-padding) var(--content-padding);
    min-height: 100vh;
    background-color: var(--bg-main);
}

/* Header Styling */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 calc(var(--content-padding) * -1) 48px;
    min-height: 96px;
    padding: 20px var(--content-padding);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 99;
}

.header-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

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

.btn-secondary {
    background-color: white;
    border-color: var(--border-color);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

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

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

.btn-danger:hover {
    background-color: #dc2626;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 16px;
}

.badge-high {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge-medium {
    background-color: var(--secondary-light);
    color: var(--secondary);
}

.badge-low {
    background-color: var(--success-light);
    color: var(--success);
}

/* Task Card Tags */
.task-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.task-tag {
    font-size: 11px;
    background-color: var(--bg-hover);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* Grid & Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 28px 36px;
}

.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    font-weight: 550;
    color: var(--text-main);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background-color: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-container:has(.searchable-select-wrapper),
.modal-container:has(.searchable-select-wrapper) .modal-body {
    overflow: visible;
}

.modal-container:has(.searchable-select-wrapper) .modal-body {
    max-height: none;
}

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

/* Alert/Toast Banner */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    background-color: white;
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

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

/* ==========================================
   Searchable Select / Combobox Component
   ========================================== */
.searchable-select-wrapper {
    position: relative;
    width: 100%;
}

.searchable-select-input {
    width: 100%;
    cursor: pointer;
    padding-right: 36px !important;
}

.searchable-select-wrapper::after {
    content: "\f078";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 12px;
    pointer-events: none;
}

/* 當 focus 時，改變下拉箭頭為向上 */
.searchable-select-wrapper.active .searchable-select-input {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.searchable-select-wrapper.active::after {
    content: "\f077";
    color: var(--primary);
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: 6px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1050;
    box-shadow: var(--shadow-lg);
    display: none;
    animation: slideDown 0.15s ease-out;
}

.searchable-select-wrapper.active .searchable-select-dropdown {
    display: block;
}

.searchable-option {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13.5px;
    color: var(--text-main);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.searchable-option:hover {
    background-color: var(--bg-hover);
}

.searchable-option.selected {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.searchable-option.selected::after {
    content: "";
    width: 6px;
    height: 10px;
    border: solid var(--primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    display: inline-block;
    margin-right: 4px;
}

.searchable-option.no-result {
    color: var(--text-muted);
    cursor: default;
    justify-content: center;
    padding: 14px;
    font-size: 13px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 側邊欄登出按鈕 */
.logout-btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: all 0.2s ease;
}

.logout-btn-icon:hover {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* ==========================================
   Tabs Component (Profile Page)
   ========================================== */
.tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 28px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    outline: none;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--primary);
    border-radius: 2px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.pagination-info {
    min-width: 150px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

@media (max-width: 900px) {
    :root {
        --content-padding: 20px;
        --sidebar-width: 0px;
    }

    .app-container {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        padding: 20px;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .brand-section {
        margin-bottom: 22px;
    }

    .nav-menu {
        flex: none;
        max-height: none;
    }

    .sidebar-support-nav {
        margin-top: 16px;
    }

    .main-content {
        width: 100%;
        flex-basis: auto;
        margin-left: 0;
    }

    .content-header {
        min-height: auto;
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .grid-container {
        grid-template-columns: 1fr;
    }
}
