/**
 * Common Styles - TugasKu Pro
 * Layout dasar, Kanban, Kalender, Modal, Embed Media & Utilitas Responsif
 */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --dark: #0f172a;
    --light: #f8fafc;
    --border-color: #e2e8f0;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    color: #334155;
    background-color: #f1f5f9;
}

/* =========================================
   LAYOUT UTAMA (DESKTOP FIRST & RESPONSIVE)
   ========================================= */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.nav-item .icon {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

/* Konten Utama */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Mencegah overflow flexbox */
}

/* Topbar / Header */
.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.content-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* =========================================
   KOMPONEN KANBAN (PEMANTAU TAHAP TUGAS)
   ========================================= */
.kanban-board {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    align-items: flex-start;
}

.kanban-column {
    flex: 0 0 310px;
    max-width: 310px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
}

.kanban-column-header {
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

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

.kanban-card {
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
}

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

.kanban-card.dragging {
    opacity: 0.4;
}

/* Badges & Pills */
.task-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.badge-urgent { background: #fee2e2; color: #991b1b; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-low { background: #f1f5f9; color: #475569; }

.badge-stage-backlog { background: #f1f5f9; color: #475569; }
.badge-stage-todo { background: #e0f2fe; color: #0369a1; }
.badge-stage-in_progress { background: #fef3c7; color: #b45309; }
.badge-stage-review { background: #f3e8ff; color: #6b21a8; }
.badge-stage-done { background: #dcfce7; color: #15803d; }

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 7px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.4rem 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* =========================================
   KOMPONEN KALENDER
   ========================================= */
.calendar-wrapper {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-collapse: collapse;
}

.calendar-day-head {
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.calendar-day-head:last-child {
    border-right: none;
}

.calendar-cell {
    min-height: 105px;
    padding: 0.4rem;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.calendar-cell:nth-child(7n) {
    border-right: none;
}

.calendar-cell.other-month {
    background: #f8fafc;
    opacity: 0.5;
}

.calendar-cell.is-today {
    background: #eff6ff;
}

.calendar-cell-num {
    font-weight: 600;
    font-size: 0.8rem;
    color: #475569;
    padding: 0.15rem 0.35rem;
    align-self: flex-start;
}

.calendar-cell.is-today .calendar-cell-num {
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
}

.calendar-event-pill {
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    font-weight: 500;
}

/* =========================================
   MODAL & DIALOG
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Tab Navigation di dalam Modal */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    background: #f8fafc;
    gap: 0.5rem;
}

.modal-tab-btn {
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
}

.modal-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-pane {
    display: none;
}

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

/* =========================================
   MEDIA EMBEDDED (VIDEO, PDF & GAMBAR)
   ========================================= */
.embed-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* Rasio 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    margin: 0.75rem 0;
    background: #000;
}

.embed-video-wrapper iframe,
.embed-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.embed-pdf-wrapper {
    width: 100%;
    height: 480px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 0.75rem 0;
}

.embed-pdf-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.image-preview-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.image-preview-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.image-preview-item:hover img {
    transform: scale(1.05);
}

/* =========================================
   CHECKLIST SUB-TUGAS & DYNAMIC PROGRESS
   ========================================= */
.subtask-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.subtask-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: background 0.15s;
}

.subtask-item.is-done {
    background: #f1f5f9;
}

.subtask-item.is-done .subtask-title {
    text-decoration: line-through;
    color: #94a3b8;
}

.subtask-checkbox {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
}

.subtask-actions {
    margin-left: auto;
    display: flex;
    gap: 0.35rem;
}

/* =========================================
   TOAST NOTIFICATION
   ========================================= */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: slideIn 0.25s ease-out;
}

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-info { background: #3b82f6; }

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

/* =========================================
   RESPONSIVE DESIGN (MOBILE FRIENDLY)
   ========================================= */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 0 0 20px rgba(0,0,0,0.2);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .btn-menu-toggle {
        display: block;
    }
    .calendar-cell {
        min-height: 80px;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 0 1rem;
    }
    .content-body {
        padding: 1rem;
    }
    .kanban-column {
        flex: 0 0 270px;
        max-width: 270px;
    }
    .calendar-cell-num {
        font-size: 0.7rem;
    }
    .calendar-day-head {
        font-size: 0.7rem;
        padding: 0.4rem;
    }
    .calendar-event-pill {
        font-size: 0.65rem;
        padding: 0.1rem 0.25rem;
    }
}
