/* AI Email Assistant - Main Stylesheet */

body {
    background-color: #f8f9fa;
}

.task-item {
    transition: all 0.3s ease;
}

.task-item:hover {
    background-color: #f1f3f5;
}

.task-completed {
    opacity: 0.6;
}

.task-completed .task-title {
    text-decoration: line-through;
}

.overdue {
    border-left: 3px solid #dc3545;
}

.upcoming {
    border-left: 3px solid #ffc107;
}

.badge-source {
    font-size: 0.7rem;
}

.stats-card {
    border-left: 4px solid;
}

.loading {
    display: none;
}

.loading.active {
    display: inline-block;
}

#refreshProgress {
    height: 5px;
    width: 100%;
    position: absolute;
    background: #000;
    left: 0;
}
#refreshBar {
    height: 100%;
    width: 0%;
    background-color: #1d88de;
}

/* AI Chat Interface */
.chat-container {
    height: 500px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    background-color: #fff;
    max-height: 50dvh;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
}

.chat-message .flex-grow-1 {
    max-width: 88%;
}

.chat-message.user {
    background-color: #e7f3ff;
    margin-left: 2rem;
    text-align: right;
}

.chat-message.assistant {
    background-color: #f8f9fa;
    margin-right: 2rem;
}

.chat-message.system {
    background-color: #fff3cd;
    text-align: center;
    font-style: italic;
}

.chat-input-container {
    position: relative;
}

.chat-input-container textarea {
    padding-right: 50px;
}

.chat-send-button {
    position: absolute;
    right: 10px;
    bottom: 15px;
}

#chatInput.voice-listening {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,.25);
}

#taskList, #priorityEmailList {
    max-height: calc(50dvh - 250px);
    overflow-y: scroll;
    scrollbar-color: #1d88de transparent;
    scrollbar-width: thin;
}
@media screen and (max-width: 500px) {
    .headerbuttons {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-evenly;
        margin: 10px;
    }
    .navbar-brand {
        margin:auto;
    }
}
/* DARK */

.dark-skin, #chatInput {
    background-color: #b3b3b33d;
    border: 1px solid transparent;
    color: #ffffff;
}

.dark-skin, #chatInput::placeholder {
    color: #9b9b9b!important;
}

.dark-skin .modal-content {
    background-color: #f7f7f7e0;
}

.dark-skin .modal-content * {
    color: #000000;
}

.dark-skin .list-group-item {
    background-color: #b3b3b33d;
}

.dark-skin .task-title, .dark-skin #priorityEmailList h6 {
    color: #ffffff;
}

.dark-skin .chat-message.user, .dark-skin .chat-message.assistant {
    color: #000000;
}
.dark-skin .list-group-item:hover {
    background-color: rgba(221, 221, 221, 0.45);
    .task-title {
        color: #000000;
    }
}

.dark-skin .list-group-flush {
    border-radius: 10px;
}

.dark-skin .chat-container {
    background-color: #b3b3b33d;
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid transparent;
}

.dark-skin .navbar {
    background: #24243E;
}

.dark-skin .card {
    background: rgb(106 106 106 / 20%);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.84);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid #454545;
}

.dark-skin .card-title, .dark-skin .card {
    color: #ffffff!important;
}

.dark-skin .text-muted {
    color: #383838!important;
}

.dark-skin #priorityEmailList .text-muted, .dark-skin #statsContainer .text-muted, .dark-skin #taskList .text-muted, .dark-skin #emailInsightsContent .text-muted {
    color: #b0b0b0!important;
}

.chat-message.system {
    background-color: #1d88de;
}

body {
    background-image: url(https://images.pexels.com/photos/176851/pexels-photo-176851.jpeg);
    background-size: auto 100dvh;
    background-attachment: fixed;
}

/* Drag and Drop v3 - Grid-Based Layout System */

/* Grid Layout Mode Active */
body.grid-layout-mode::before {
    content: "🎯 GRID MODE - Drag cards to any grid position • Click arrows to resize";
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: #000;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    z-index: 10000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Layout Grid Overlay */
.layout-grid {
    position: fixed;
    top: 120px;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(12, 1fr);
    gap: 0;
    pointer-events: none;
    z-index: 9998;
    padding: 0 16px;
}

.grid-cell {
    border: 1px dashed rgba(13, 110, 253, 0.15);
    position: relative;
    pointer-events: all;
    transition: all 0.2s ease;
    background: transparent;
}

.grid-cell:hover {
    background: rgba(13, 110, 253, 0.05);
    border-color: rgba(13, 110, 253, 0.4);
}

.grid-cell-highlight {
    background: rgba(13, 110, 253, 0.2) !important;
    border: 2px solid #0d6efd !important;
    z-index: 9999;
}

.grid-cell-highlight::after {
    content: "Drop here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #0d6efd;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none;
}

/* Grid Column Labels */
.grid-col-label {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: #6c757d;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 4px;
    border-radius: 2px;
    pointer-events: none;
}

.dark-skin .grid-col-label {
    background: rgba(33, 37, 41, 0.9);
    color: #adb5bd;
}

/* Draggable Widgets */
.draggable-widget {
    cursor: move;
    position: relative;
    z-index: 10;
    transition: all 0.2s ease;
}

.draggable-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dragging {
    opacity: 0.6;
    transform: scale(0.95) rotate(2deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10001 !important;
    cursor: grabbing !important;
}

/* Widget Badge */
.widget-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #0d6efd;
    border-radius: 8px;
    padding: 8px 12px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
    pointer-events: auto;
}

/* Make sure parent column is positioned */
[data-widget-id] {
    position: relative;
}

.dark-skin .widget-badge {
    background: rgba(33, 37, 41, 0.98);
    border-color: #0d6efd;
}

.widget-id {
    font-size: 11px;
    font-weight: bold;
    color: #0d6efd;
    font-family: 'Courier New', monospace;
    text-align: center;
    padding: 2px 4px;
    background: rgba(13, 110, 253, 0.1);
    border-radius: 3px;
}

.widget-size {
    font-size: 9px;
    color: #6c757d;
    text-align: center;
    font-family: monospace;
}

.widget-resize {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.resize-btn {
    background: #0d6efd;
    color: white;
    border: none;
    width: 28px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.resize-btn:hover {
    background: #0b5ed7;
    transform: scale(1.1);
}

.resize-btn:active {
    transform: scale(0.95);
}

/* Hide widget badges while dragging */
.dragging .widget-badge {
    display: none;
}

/* Prevent text selection in grid mode */
body.grid-layout-mode * {
    user-select: none;
    -webkit-user-select: none;
}

/* Dark Mode Grid */
.dark-skin .grid-cell {
    border-color: rgba(13, 110, 253, 0.2);
}

.dark-skin .grid-cell:hover {
    background: rgba(13, 110, 253, 0.08);
    border-color: rgba(13, 110, 253, 0.5);
}

.dark-skin .grid-cell-highlight {
    background: rgba(13, 110, 253, 0.25) !important;
}

/* Adjust main content position when grid is active */
body.grid-layout-mode .m-4 {
    position: relative;
    z-index: 9997;
    margin-top: 120px;
}

body.grid-layout-mode .m-4 > .row {
    position: relative;
    z-index: 10;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #0d6efd;
    border-radius: 8px;
    padding: 12px;
    max-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 10002;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    font-size: 12px;
}

.dark-skin .debug-panel {
    background: rgba(33, 37, 41, 0.98);
    color: #f8f9fa;
}

.debug-panel h6 {
    margin: 0 0 8px 0;
    color: #0d6efd;
    font-weight: bold;
}

.debug-panel ul {
    margin: 0;
    padding-left: 16px;
    list-style: none;
}

.debug-panel li {
    padding: 4px 0;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.debug-panel li::before {
    content: "✓ ";
    color: #28a745;
    font-weight: bold;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body.grid-layout-mode::before {
        font-size: 11px;
        padding: 8px 16px;
        top: 60px;
    }
    
    .layout-grid {
        top: 100px;
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(12, 1fr);
    }
    
    .widget-badge {
        min-width: 120px;
        padding: 6px 8px;
        gap: 4px;
    }
    
    .widget-id {
        font-size: 10px;
    }
    
    .widget-size {
        font-size: 8px;
    }
    
    .resize-btn {
        width: 24px;
        height: 20px;
        font-size: 11px;
    }
    
    .grid-col-label {
        font-size: 8px;
    }
}

/* Animation for drop */
@keyframes dropFlash {
    0%, 100% {
        background: rgba(13, 110, 253, 0.2);
    }
    50% {
        background: rgba(13, 110, 253, 0.4);
    }
}

.grid-cell.drop-animation {
    animation: dropFlash 0.3s ease;
}