/* ==========================================================================
   GOOGLE MATERIAL 3 DESIGN SYSTEM & VARIABLES
   ========================================================================== */

:root {
    --font-primary: 'Outfit', 'Roboto', 'Sarabun', -apple-system, sans-serif;
    --transition-speed: 0.2s;
    --transition-ease: cubic-bezier(0.2, 0, 0, 1);
}

/* Light Theme (Google Workspace Clean White) - Default */
.light-theme {
    --bg-main: #f8f9fa; /* Google Workspace background */
    --bg-glass: 255, 255, 255;
    --bg-card: #ffffff;
    
    --text-primary: #202124; /* Google dark grey */
    --text-secondary: #5f6368; /* Google grey */
    --text-muted: #80868b;
    
    --primary: #1a73e8; /* Google Blue */
    --primary-hover: #1557b0;
    --primary-trans: rgba(26, 115, 232, 0.08);
    --primary-gradient: linear-gradient(135deg, #1a73e8 0%, #1e88e5 100%);
    
    --border-color: #dadce0;
    --border-hover: #bdc1c6;
    --shadow-color: rgba(60, 64, 67, 0.15);
    --card-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    
    /* Kanban Columns */
    --bg-column: #f1f3f4;
    
    /* Google Quad-Color Accent Palette */
    --color-todo: #1a73e8; /* Google Blue */
    --color-todo-bg: rgba(26, 115, 232, 0.1);
    
    --color-progress: #f29900; /* Google Orange/Yellow */
    --color-progress-bg: rgba(242, 153, 0, 0.1);
    
    --color-done: #1e8e3e; /* Google Green */
    --color-done-bg: rgba(30, 142, 62, 0.1);
    
    --color-red: #d93025; /* Google Red */
    --color-red-bg: rgba(217, 48, 37, 0.1);

    --orb-color-1: rgba(26, 115, 232, 0.05);
    --orb-color-2: rgba(30, 142, 62, 0.04);
    --orb-color-3: rgba(242, 153, 0, 0.03);
}

/* Dark Theme (Google Material Dark) */
.dark-theme {
    --bg-main: #1f1f1f;
    --bg-glass: 32, 33, 36;
    --bg-card: #2d2d2d;
    
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #80868b;
    
    --primary: #8ab4f8; /* Google Light Blue */
    --primary-hover: #aecbfa;
    --primary-trans: rgba(138, 180, 248, 0.16);
    --primary-gradient: linear-gradient(135deg, #8ab4f8 0%, #64b5f6 100%);
    
    --border-color: #3c4043;
    --border-hover: #5f6368;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    
    /* Kanban Columns */
    --bg-column: #202124;
    
    /* Google Quad-Color Accent Palette (Dark version) */
    --color-todo: #8ab4f8;
    --color-todo-bg: rgba(138, 180, 248, 0.12);
    
    --color-progress: #fdd663;
    --color-progress-bg: rgba(253, 214, 99, 0.12);
    
    --color-done: #81c995;
    --color-done-bg: rgba(129, 201, 149, 0.12);
    
    --color-red: #f28b82;
    --color-red-bg: rgba(242, 139, 130, 0.12);

    --orb-color-1: rgba(138, 180, 248, 0.1);
    --orb-color-2: rgba(129, 201, 149, 0.08);
    --orb-color-3: rgba(253, 214, 99, 0.06);
}

/* ==========================================================================
   BASE STYLES & RESET
   ========================================================================== */

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background-color var(--transition-speed) var(--transition-ease),
                color var(--transition-speed) var(--transition-ease);
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Floating Background Orbs (Google soft glow style) */
.bg-orbs {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    display: block;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(130px);
    opacity: 0.75;
}

.orb-1 {
    width: 50vw;
    height: 50vw;
    top: -15vw;
    left: -10vw;
    background-color: var(--orb-color-1);
    animation: floatOrb 30s infinite alternate ease-in-out;
}

.orb-2 {
    width: 45vw;
    height: 45vw;
    bottom: -10vw;
    right: -10vw;
    background-color: var(--orb-color-2);
    animation: floatOrb 25s infinite alternate-reverse ease-in-out;
}

.orb-3 {
    width: 30vw;
    height: 30vw;
    top: 30%;
    left: 45%;
    background-color: var(--orb-color-3);
    animation: floatOrb 20s infinite alternate ease-in-out;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(4%, 6%) scale(1.03); }
    100% { transform: translate(-4%, -3%) scale(0.97); }
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.4);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.text-danger {
    color: var(--color-red);
}

.text-center {
    text-align: center;
}

/* ==========================================================================
   BUTTONS & INPUTS (Google Pill & Flat Card Shapes)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 24px; /* Fully rounded Google pill button */
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-ease);
    border: 1px solid transparent;
    font-family: var(--font-primary);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
}

.btn-primary:active {
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3);
}

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

.btn-secondary:hover {
    background-color: rgba(128, 128, 128, 0.05);
    border-color: var(--border-hover);
}

.btn-danger {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--color-red);
}

.btn-danger:hover {
    background-color: var(--color-red-bg);
    border-color: var(--color-red);
}

.btn-icon {
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-icon:hover {
    background-color: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* Google style Inputs: Grey backdrop, active blue bottom line / focus border */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(128, 128, 128, 0.07);
    border: 1px solid transparent;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.92rem;
    outline: none;
    transition: all var(--transition-speed);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary-trans);
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: rgba(128, 128, 128, 0.03) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.help-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ==========================================================================
   NAVIGATION BAR
   ========================================================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.brand-icon {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.brand-name {
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.brand-name .highlight {
    color: var(--primary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(128, 128, 128, 0.08);
    padding: 4px 12px 4px 4px;
    border-radius: 18px;
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    overflow: hidden;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 500;
}

.user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ==========================================================================
   LOGIN MODULE
   ========================================================================== */

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 70px);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 32px 24px;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    animation: fadeInScale 0.3s var(--transition-ease);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.logo-box {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.logo-icon {
    width: 26px;
    height: 26px;
    color: white;
}

.login-header h1 {
    font-size: 1.45rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-toggle-pwd {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.error-msg {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-red-bg);
    border: 1px solid rgba(217, 48, 37, 0.15);
    color: var(--color-red);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.8rem;
}

/* ==========================================================================
   ADMIN DASHBOARD VIEW
   ========================================================================== */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dashboard-header h2 {
    font-size: 1.5rem;
    font-weight: 400;
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    width: 20px;
    height: 20px;
}

.stat-details h3 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Glowing border highlights for Stats Cards */
.stat-card:nth-child(1) { border-left: 4px solid var(--color-todo); }
.stat-card:nth-child(2) { border-left: 4px solid var(--color-progress); }
.stat-card:nth-child(3) { border-left: 4px solid var(--color-done); }
.stat-card:nth-child(4) { border-left: 4px solid var(--color-red); }

/* Charts Layout Grid */
.charts-row {
    display: grid;
    grid-template-columns: 1.1fr 1.3fr;
    gap: 20px;
    margin-bottom: 24px;
    animation: slideUp 0.5s ease;
}

@media (max-width: 968px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

.chart-panel {
    display: flex;
    flex-direction: column;
}

/* Donut Chart Layout */
.chart-body-donut {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 12px;
}

.donut-chart-container {
    position: relative;
    width: 150px;
    height: 150px;
}

.donut-chart {
    transform: rotate(-90deg); /* Start circular segments from 12 o'clock */
}

.donut-ring-base {
    stroke: rgba(0, 0, 0, 0.04);
}

.dark-theme .donut-ring-base {
    stroke: rgba(255, 255, 255, 0.05);
}

.donut-segment {
    transition: stroke-dashoffset 0.5s var(--transition-ease);
    stroke-linecap: round; /* Rounded edges for premium Apple look */
}

.donut-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    text-align: center;
}

.donut-center-num {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.donut-center-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 3px;
}

/* Chart Legend Styling */
.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 130px;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    gap: 10px;
}

.legend-key {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-val {
    font-weight: 600;
    color: var(--text-primary);
}

/* Bar Chart Layout for Workload */
.bar-chart-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 0;
}

.bar-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bar-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 500;
}

.bar-label-name {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.bar-label-count {
    color: var(--text-muted);
    font-weight: 600;
}

.bar-outer {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    overflow: hidden;
}

.dark-theme .bar-outer {
    background: rgba(255, 255, 255, 0.05);
}

.bar-inner {
    height: 100%;
    background-color: var(--primary);
    background-image: var(--primary-gradient);
    border-radius: 4px;
    width: 0;
    transition: width 0.7s var(--transition-ease);
}

/* Admin Grid Layout */
.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 3.1fr) minmax(0, 0.9fr);
    gap: 20px;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3);
    border-radius: 12px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 500;
}

.filters-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    width: 14px;
    height: 14px;
}

.search-box input {
    padding: 6px 12px 6px 32px;
    font-size: 0.85rem;
    width: 180px;
    border-radius: 8px;
}

.card-header select {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.card-body {
    padding: 16px 20px;
}

/* Fiscal Year Tab buttons (Google Pill segment selector look) */
.fiscal-tabs {
    display: inline-flex;
    background: rgba(128, 128, 128, 0.08);
    padding: 3px;
    border-radius: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.fiscal-tab-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: 18px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-primary);
    transition: all var(--transition-speed) var(--transition-ease);
}

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

.fiscal-tab-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.15);
    font-weight: 500;
}

/* Task Table Wrap Constraints (ป้องกันตกบรรทัดเด็ดขาด) */
/* Task Table Wrap Constraints (ป้องกันตกบรรทัดเด็ดขาด) */
.task-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.84rem; /* ลดขนาดตัวอักษรลงเล็กน้อยเพื่อประหยัดพื้นที่ */
}

.table-responsive {
    width: 100%;
    max-height: 480px; /* จำกัดความสูงของตารางงานแดชบอร์ด */
    overflow-y: auto; /* เลื่อนแนวตั้งเท่านั้น */
    overflow-x: hidden; /* ห้ามเลื่อนแนวนอน */
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: 8px;
}

.task-table th,
.task-table td {
    padding: 8px 10px; /* ลดระยะห่างเซลล์เพื่อให้คอลัมน์กว้างพอดี */
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* บังคับห้ามข้อความในตารางตกบรรทัดเด็ดขาด */
.task-table th,
.task-table td {
    white-space: nowrap; 
}

/* อนุญาตให้เฉพาะชื่อและรายละเอียดงานตกบรรทัดได้แบบควบคุม */
.task-table td:nth-child(2) {
    white-space: normal !important;
    max-width: 220px; /* ลดความกว้างของชื่องานลงเพื่อประหยัดพื้นที่ */
    word-break: break-word;
}

.task-table th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.8rem;
    position: sticky; /* ตรึงหัวตารางไว้ด้านบนเมื่อเลื่อนแนวตั้ง */
    top: 0;
    background-color: var(--bg-card);
    z-index: 10;
    box-shadow: inset 0 -1px 0 var(--border-color); /* ลากเส้นขอบล่างเมื่อ sticky */
}

.task-table tbody tr:hover {
    background-color: rgba(128, 128, 128, 0.03);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap; /* ห้าม badge ตกบรรทัด */
}

.badge-todo { background-color: var(--color-todo-bg); color: var(--color-todo); }
.badge-progress { background-color: var(--color-progress-bg); color: var(--color-progress); }
.badge-done { background-color: var(--color-done-bg); color: var(--color-done); }
.badge-danger { background-color: var(--color-red-bg); color: var(--color-red); }

/* Parent/Project indicator badge */
.project-tag {
    background-color: rgba(128, 128, 128, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-right: 6px;
    white-space: nowrap;
}

/* Subtask Row Tree layout */
.subtask-row td:nth-child(2) {
    padding-left: 36px !important;
    position: relative;
}

.subtask-tree-line {
    position: absolute;
    left: 18px;
    top: 0;
    bottom: 50%;
    width: 10px;
    border-left: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    border-bottom-left-radius: 4px;
    opacity: 0.5;
}

/* Checkbox Style */
.task-table input[type="checkbox"] {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}

/* Side container column for panels */
.admin-side-panels {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.member-card, .project-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(128, 128, 128, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.member-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-trans);
    color: var(--primary);
    font-weight: 500;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar img,
.member-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.member-name, .project-name {
    font-weight: 500;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action buttons and cell in task table / list panels */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-ease);
    padding: 0;
    flex-shrink: 0;
}

.btn-action:hover {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
}

.btn-action.edit:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-action.delete:hover {
    color: var(--color-red);
    border-color: var(--color-red);
}

.btn-action i,
.btn-action svg {
    width: 13px;
    height: 13px;
    display: block;
}

.actions-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

/* Column width constraints for task-table on desktop/tablet */
@media (min-width: 769px) {
    .task-table {
        table-layout: fixed;
        width: 100%;
    }
    .task-table th:nth-child(1),
    .task-table td:nth-child(1) {
        width: 40px;
        text-align: center;
    }
    .task-table th:nth-child(2),
    .task-table td:nth-child(2) {
        width: auto; /* takes remaining space */
    }
    .task-table th:nth-child(3),
    .task-table td:nth-child(3) {
        width: 140px;
    }
    .task-table th:nth-child(4),
    .task-table td:nth-child(4) {
        width: 90px;
    }
    .task-table th:nth-child(5),
    .task-table td:nth-child(5) {
        width: 100px;
        white-space: normal !important;
    }
    .task-table th:nth-child(6),
    .task-table td:nth-child(6) {
        width: 95px;
    }
    .task-table th:nth-child(7),
    .task-table td:nth-child(7) {
        width: 75px;
        text-align: center;
    }
    
    /* Ellipsis for long assignee name inside task table */
    .task-table td:nth-child(3) > div {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }
    .task-table td:nth-child(3) > div > span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }
}

/* ==========================================================================
   KANBAN BOARD VIEW
   ========================================================================== */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: start;
}

.kanban-column {
    background: var(--bg-column);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: 72vh;
}

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

#col-todo { border-top: 3px solid var(--color-todo); }
#col-in-progress { border-top: 3px solid var(--color-progress); }
#col-done { border-top: 3px solid var(--color-done); }

#col-todo .column-header { background: rgba(26, 115, 232, 0.02); }
#col-in-progress .column-header { background: rgba(242, 153, 0, 0.02); }
#col-done .column-header { background: rgba(30, 142, 62, 0.02); }

.dark-theme #col-todo .column-header { background: rgba(138, 180, 248, 0.02); }
.dark-theme #col-in-progress .column-header { background: rgba(253, 214, 99, 0.02); }
.dark-theme #col-done .column-header { background: rgba(129, 201, 149, 0.02); }

.column-title-box h3 {
    font-size: 0.95rem;
    font-weight: 500;
}

.task-count {
    font-size: 0.72rem;
    font-weight: 500;
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid var(--border-color);
    padding: 1px 6px;
    border-radius: 10px;
}

.kanban-cards {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 120px;
    flex-grow: 1;
}

.kanban-cards.drag-over {
    background: rgba(26, 115, 232, 0.03);
    outline: 1.5px dashed var(--primary);
    outline-offset: -3px;
    border-radius: 0 0 12px 12px;
}

/* Kanban Task Card */
.kanban-card-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    cursor: grab;
    transition: all 0.2s var(--transition-ease);
    position: relative;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3);
}

.kanban-card-item:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
}

.kanban-card-item:active {
    cursor: grabbing;
}

.kanban-card-item.dragging {
    opacity: 0.35;
    transform: scale(0.96);
}

.card-project-indicator {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.card-project-indicator i {
    width: 12px;
    height: 12px;
    color: var(--primary);
}

.task-card-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.35;
}

.task-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

.meta-date {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.meta-date i {
    width: 12px;
    height: 12px;
}

.meta-date.overdue {
    color: var(--color-red);
    font-weight: 600;
}

.card-notes-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.card-notes-indicator i {
    width: 12px;
    height: 12px;
}

/* Card action menus */
.card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.kanban-card-item:hover .card-actions {
    opacity: 1;
}

.btn-card-action {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-card-action:hover {
    color: var(--text-primary);
    background: rgba(128, 128, 128, 0.1);
}

.btn-card-action.edit:hover { color: var(--primary); }
.btn-card-action.delete:hover { color: var(--color-red); }

/* ==========================================================================
   TASK NOTES STYLING (Inside Task Modal)
   ========================================================================== */

.notes-heading {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notes-list {
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.note-item {
    background: rgba(128, 128, 128, 0.04);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.note-text {
    line-height: 1.35;
    word-break: break-word;
    color: var(--text-secondary);
}

.add-note-box {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.add-note-box textarea {
    flex-grow: 1;
    padding: 8px 12px;
    border-radius: 8px;
    resize: none;
    font-size: 0.85rem;
    min-height: 36px;
    max-height: 80px;
}

.add-note-box .btn {
    height: 36px;
    width: 36px;
    padding: 0;
    border-radius: 8px;
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: slideUpModal 0.3s var(--transition-ease);
}

.modal-card.modal-sm {
    max-width: 360px;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ==========================================================================
   TOASTS
   ========================================================================== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
    min-width: 240px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: toastIn 0.25s var(--transition-ease), toastOut 0.25s 2.75s forwards;
}

.toast.success { border-left: 4px solid var(--color-done); }
.toast.success i { color: var(--color-done); }
.toast.error { border-left: 4px solid var(--color-red); }
.toast.error i { color: var(--color-red); }

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpModal {
    from { transform: translateY(30px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes fadeInScale {
    from { transform: scale(0.98); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes toastIn {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    to { transform: translateY(12px); opacity: 0; }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 968px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
    
    .kanban-board {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .kanban-column {
        max-height: 420px;
    }
}

@media (max-width: 640px) {
    .nav-container {
        padding: 10px 14px;
    }
    
    .user-badge {
        padding: 3px 6px;
    }
    
    .user-name, .user-role {
        display: none;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* ==========================================================================
   STATUS LEFT BORDERS & RESPONSIVE DEVICE OPTIMIZATION
   ========================================================================== */

/* Table status row left border indicator for desktop view */
.task-table tbody tr.tr-status-todo td:first-child {
    border-left: 5px solid var(--color-todo) !important;
}
.task-table tbody tr.tr-status-progress td:first-child {
    border-left: 5px solid var(--color-progress) !important;
}
.task-table tbody tr.tr-status-done td:first-child {
    border-left: 5px solid var(--color-done) !important;
}
.task-table tbody tr.tr-status-overdue td:first-child {
    border-left: 5px solid var(--color-red) !important;
}

/* Sorting select style */
#admin-sort-by {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

#admin-sort-by:hover {
    border-color: var(--border-hover);
}

/* Mobile & Tablet Card Layout Transformation */
@media (max-width: 768px) {
    .task-table, 
    .task-table thead, 
    .task-table tbody, 
    .task-table tr, 
    .task-table th, 
    .task-table td {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
    }
    
    .task-table thead {
        display: none; /* Hide header columns */
    }
    
    /* Project Header Rows on Mobile */
    .task-table tr.project-header-row {
        background: rgba(128, 128, 128, 0.08) !important;
        border-radius: 8px;
        margin-top: 20px;
        margin-bottom: 8px;
        padding: 4px;
        border: none !important;
    }
    
    .task-table tr.project-header-row td {
        border: none !important;
        display: block !important;
        padding: 8px 12px !important;
    }
    
    /* Task Rows converted to Cards */
    .task-table tbody tr:not(.project-header-row) {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        position: relative;
    }
    
    /* Reset borders on mobile card cells */
    .task-table tbody tr:not(.project-header-row) td {
        border-bottom: none !important;
        padding: 6px 0 !important;
        white-space: normal !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    /* Apply borders directly on the card itself for mobile */
    .task-table tbody tr.tr-status-todo { border-left: 5px solid var(--color-todo) !important; }
    .task-table tbody tr.tr-status-progress { border-left: 5px solid var(--color-progress) !important; }
    .task-table tbody tr.tr-status-done { border-left: 5px solid var(--color-done) !important; }
    .task-table tbody tr.tr-status-overdue { border-left: 5px solid var(--color-red) !important; }
    
    /* Reset first cell border left on mobile cards */
    .task-table tbody tr.tr-status-todo td:first-child,
    .task-table tbody tr.tr-status-progress td:first-child,
    .task-table tbody tr.tr-status-done td:first-child,
    .task-table tbody tr.tr-status-overdue td:first-child {
        border-left: none !important;
    }
    
    /* Inject label prefixes */
    .task-table tbody tr:not(.project-header-row) td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--text-muted);
        font-size: 0.76rem;
        margin-right: 16px;
        flex-shrink: 0;
    }
    
    /* Specific cell styling for mobile cards */
    .task-table tbody tr:not(.project-header-row) td:first-child {
        justify-content: flex-start;
        border-bottom: 1px dashed var(--border-color) !important;
        padding-bottom: 8px !important;
        margin-bottom: 6px;
    }
    .task-table tbody tr:not(.project-header-row) td:first-child::before {
        margin-right: 8px;
    }
    
    .task-table tbody tr:not(.project-header-row) td:nth-child(2) {
        display: block !important;
        border-bottom: 1px dashed var(--border-color) !important;
        padding-bottom: 8px !important;
        margin-bottom: 8px;
    }
    .task-table tbody tr:not(.project-header-row) td:nth-child(2)::before {
        display: none;
    }
    
    .task-table tbody tr:not(.project-header-row) td:last-child {
        justify-content: flex-end;
        border-top: 1px solid var(--border-color) !important;
        padding-top: 8px !important;
        margin-top: 6px;
    }
    
    .subtask-row td:nth-child(2) {
        padding-left: 20px !important;
    }
    .subtask-tree-line {
        left: 6px;
        top: -6px;
    }
}

/* Vertical stacking filters for phones */
@media (max-width: 640px) {
    .filters-row {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
        gap: 8px !important;
    }
    .filters-row select, .search-box, .search-box input, .group-project-toggle {
        width: 100% !important;
    }
    .action-buttons {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-top: 8px;
    }
    .action-buttons button {
        width: 100% !important;
    }
}

/* Navigation Menu Tabs */
.nav-menu {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 24px;
}
.nav-menu-btn {
    display: inline-flex;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 20px;
    transition: all var(--transition-speed) var(--transition-ease);
    font-family: var(--font-primary);
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}
.nav-menu-btn:hover {
    background: rgba(128, 128, 128, 0.08);
    color: var(--text-primary);
}
.nav-menu-btn.active {
    background: var(--primary-trans);
    color: var(--primary);
    font-weight: 600;
}
.nav-menu-btn i,
.nav-menu-btn svg {
    width: 16px;
    height: 16px;
}

/* Calendar Styling */
.calendar-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.controls-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nav-arrows {
    display: flex;
    align-items: center;
    gap: 4px;
}
.month-year-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
    min-width: 160px;
    text-align: center;
}
.calendar-legend {
    display: flex;
    gap: 12px;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}
.legend-color.color-task { background-color: var(--primary); }
.legend-color.color-event { background-color: var(--color-red); }

/* Calendar Grid */
.calendar-container {
    width: 100%;
    display: flex;
    flex-direction: column;
}
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 8px;
}
.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(100px, 1fr);
    gap: 6px;
}
.calendar-day-cell {
    background: rgba(128, 128, 128, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.2s ease;
    overflow: hidden;
    position: relative;
    min-width: 0;
}
.calendar-day-cell:hover {
    background: rgba(128, 128, 128, 0.05);
}
.calendar-day-cell.other-month {
    opacity: 0.35;
}
.calendar-day-cell.today {
    background: rgba(26, 115, 232, 0.05);
    border-color: var(--primary);
}
.calendar-day-cell.today .day-number {
    background: var(--primary);
    color: white;
    font-weight: 600;
}
.day-number {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 4px;
}

/* Calendar Cards (Tasks and Events) */
.calendar-item {
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    transition: opacity 0.2s ease;
}
.calendar-item:hover {
    opacity: 0.85;
}
.calendar-item.cal-task-item {
    background: var(--primary-trans);
    color: var(--primary);
    border: 1px solid rgba(26, 115, 232, 0.15);
}
.calendar-item.cal-task-item.done {
    background: var(--color-done-bg);
    color: var(--color-done);
    border-color: rgba(30, 142, 62, 0.15);
    text-decoration: line-through;
}
.calendar-item.cal-task-item.overdue {
    background: var(--color-red-bg);
    color: var(--color-red);
    border-color: rgba(217, 48, 37, 0.15);
}

.calendar-item.cal-event-item {
    background: var(--color-red-bg);
    color: var(--color-red);
    border: 1px solid rgba(217, 48, 37, 0.2);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.calendar-item.cal-event-item i,
.calendar-item.cal-event-item svg {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
}

.calendar-more-btn {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    padding: 1px 4px;
    font-weight: 500;
}
.calendar-more-btn:hover {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .nav-menu {
        margin-left: 12px;
        gap: 4px;
    }
    .nav-menu-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    .nav-menu-btn span {
        display: none;
    }
    .calendar-days {
        grid-auto-rows: minmax(80px, 1fr);
    }
    .calendar-legend {
        display: none;
    }
}

.user-avatar,
.member-avatar {
    background: transparent !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar img,
.member-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50% !important;
    object-fit: cover;
    display: block;
}

.user-avatar span,
.member-avatar span {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.user-avatar span {
    background-color: var(--primary);
    color: white;
}

.member-avatar span {
    background-color: var(--primary-trans);
    color: var(--primary);
}
