/* ================================================
   DASHBOARD WIDGETS — ProductiveApp v4.2
   Drag & drop customizable grid
   ================================================ */

/* ── Widget Grid ─────────────────────────────────── */
#dw-grid-container {
    margin-bottom: 28px;
}

.dw-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .dw-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Widget Card ─────────────────────────────────── */
.dw-widget {
    background: var(--bg-secondary, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.07));
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dw-widget:hover {
    border-color: color-mix(in srgb, var(--accent, #8b5cf6) 30%, transparent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.dw-widget--full {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .dw-widget--full {
        grid-column: span 1;
    }
}

/* ── Widget Header ───────────────────────────────── */
.dw-widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
}

.dw-widget-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.dw-widget-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #f4f4f5);
    flex: 1;
    letter-spacing: -0.01em;
}

/* ── Widget Body ─────────────────────────────────── */
.dw-widget-body {
    padding: 16px 18px;
    min-height: 80px;
}

/* ── Loading spinner ─────────────────────────────── */
.dw-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.dw-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border, rgba(255, 255, 255, 0.1));
    border-top-color: var(--accent, #8b5cf6);
    border-radius: 50%;
    animation: dw-spin 0.7s linear infinite;
}

@keyframes dw-spin {
    to { transform: rotate(360deg); }
}

/* ── Empty state ─────────────────────────────────── */
.dw-empty {
    text-align: center;
    padding: 20px 12px;
    color: var(--text-tertiary, #71717a);
    font-size: 13px;
}

/* ================================================
   EDIT MODE
   ================================================ */

/* Edit toolbar */
.dw-edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: color-mix(in srgb, var(--accent, #8b5cf6) 8%, var(--bg-secondary, #1a1a2e));
    border: 1px solid color-mix(in srgb, var(--accent, #8b5cf6) 20%, transparent);
    border-radius: 14px;
    margin-bottom: 14px;
    animation: dw-fadeIn 0.25s ease;
}

.dw-edit-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #f4f4f5);
}

.dw-edit-actions {
    display: flex;
    gap: 8px;
}

.dw-edit-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    transition: background 0.15s, color 0.15s;
}

.dw-edit-btn--reset {
    background: transparent;
    color: var(--text-secondary, #a1a1aa);
}

.dw-edit-btn--reset:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #f4f4f5);
}

.dw-edit-btn--done {
    background: var(--accent, #8b5cf6);
    color: #fff;
    border-color: var(--accent, #8b5cf6);
}

.dw-edit-btn--done:hover {
    opacity: 0.85;
}

/* Hidden widgets restore panel */
.dw-hidden-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.02));
    border: 1px dashed var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.dw-hidden-label {
    font-size: 12px;
    color: var(--text-tertiary, #71717a);
    font-weight: 500;
}

.dw-hidden-restore {
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 12px;
    background: color-mix(in srgb, var(--accent, #8b5cf6) 12%, transparent);
    color: var(--accent-light, var(--accent, #8b5cf6));
    border: 1px solid color-mix(in srgb, var(--accent, #8b5cf6) 25%, transparent);
    cursor: pointer;
    transition: background 0.15s;
}

.dw-hidden-restore:hover {
    background: color-mix(in srgb, var(--accent, #8b5cf6) 22%, transparent);
}

/* Editing widget state */
.dw-widget--editing {
    cursor: grab;
    border-style: dashed;
    border-color: color-mix(in srgb, var(--accent, #8b5cf6) 30%, transparent);
}

.dw-widget--editing:active {
    cursor: grabbing;
}

.dw-drag-handle {
    font-size: 18px;
    color: var(--text-tertiary, #52525b);
    cursor: grab;
    user-select: none;
    line-height: 1;
    letter-spacing: 1px;
}

.dw-widget-hide {
    background: none;
    border: none;
    color: var(--text-tertiary, #52525b);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    margin-left: auto;
}

.dw-widget-hide:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Drag states */
.dw-dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.dw-drop-indicator {
    border-color: var(--accent, #8b5cf6) !important;
    border-style: solid !important;
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent, #8b5cf6) 20%, transparent) !important;
}

/* ================================================
   WIDGET: MÉTÉO BUSINESS
   ================================================ */
.dw-meteo-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dw-meteo-item {
    flex: 1;
    min-width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.dw-meteo-item:hover {
    background: color-mix(in srgb, var(--accent, #8b5cf6) 8%, transparent);
}

.dw-meteo-icon {
    font-size: 20px;
}

.dw-meteo-val {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #f4f4f5);
    line-height: 1;
}

.dw-meteo-val small {
    font-size: 14px;
    color: var(--text-tertiary, #71717a);
    font-weight: 500;
}

.dw-meteo-label {
    font-size: 11px;
    color: var(--text-tertiary, #71717a);
    text-align: center;
}

/* ================================================
   WIDGET: OBJECTIFS SEMAINE
   ================================================ */
.dw-objectifs-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dw-obj-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dw-obj-pct {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary, #f4f4f5);
    line-height: 1;
}

.dw-obj-bar-track {
    height: 8px;
    background: var(--bg-card, rgba(255, 255, 255, 0.06));
    border-radius: 4px;
    overflow: hidden;
}

.dw-obj-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease-out;
}

.dw-obj-detail {
    font-size: 12px;
    color: var(--text-tertiary, #71717a);
}

.dw-obj-meta {
    display: flex;
    gap: 16px;
}

.dw-obj-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dw-obj-meta-val {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #f4f4f5);
}

.dw-obj-meta-label {
    font-size: 11px;
    color: var(--text-tertiary, #71717a);
}

/* ================================================
   WIDGET: PROCHAINS RDV
   ================================================ */
.dw-rdv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dw-rdv-item {
    display: flex;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.dw-rdv-item:hover {
    background: color-mix(in srgb, var(--accent, #8b5cf6) 8%, transparent);
}

.dw-rdv-date {
    flex-shrink: 0;
    text-align: center;
    min-width: 70px;
}

.dw-rdv-day {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light, var(--accent, #8b5cf6));
}

.dw-rdv-time {
    font-size: 11px;
    color: var(--text-tertiary, #71717a);
    margin-top: 2px;
}

.dw-rdv-info {
    flex: 1;
    min-width: 0;
}

.dw-rdv-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #f4f4f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dw-rdv-type {
    font-size: 11px;
    color: var(--text-tertiary, #71717a);
    margin-top: 2px;
    text-transform: capitalize;
}

/* ================================================
   WIDGET: DERNIERS DEALS CRM
   ================================================ */
.dw-deals-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dw-deal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.dw-deal-item:hover {
    background: color-mix(in srgb, var(--accent, #8b5cf6) 8%, transparent);
}

.dw-deal-main {
    flex: 1;
    min-width: 0;
}

.dw-deal-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #f4f4f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dw-deal-contact {
    font-size: 11px;
    color: var(--text-tertiary, #71717a);
    margin-top: 2px;
}

.dw-deal-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.dw-deal-amount {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #f4f4f5);
}

.dw-deal-stage {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ================================================
   WIDGET: FLUX D'ACTIVITÉ
   ================================================ */
.dw-activity-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.dw-activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}

.dw-activity-item:hover {
    background: color-mix(in srgb, var(--accent, #8b5cf6) 8%, transparent);
}

.dw-activity-icon {
    font-size: 15px;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card, rgba(255, 255, 255, 0.04));
    border-radius: 8px;
}

.dw-activity-body {
    flex: 1;
    min-width: 0;
}

.dw-activity-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary, #f4f4f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dw-activity-meta {
    font-size: 11px;
    color: var(--text-tertiary, #71717a);
    margin-top: 1px;
}

.dw-activity-module {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent, #8b5cf6);
    opacity: 0.8;
}

.dw-activity-time {
    font-size: 11px;
    color: var(--text-tertiary, #52525b);
    flex-shrink: 0;
    font-weight: 500;
}

/* ── Scrollbar for activity widget ───────────────── */
.dw-activity-list::-webkit-scrollbar {
    width: 4px;
}

.dw-activity-list::-webkit-scrollbar-track {
    background: transparent;
}

.dw-activity-list::-webkit-scrollbar-thumb {
    background: var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 2px;
}

/* ── Animations ──────────────────────────────────── */
@keyframes dw-fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dw-widget {
    animation: dw-fadeIn 0.3s ease both;
}

.dw-widget:nth-child(2) { animation-delay: 0.05s; }
.dw-widget:nth-child(3) { animation-delay: 0.1s; }
.dw-widget:nth-child(4) { animation-delay: 0.15s; }
.dw-widget:nth-child(5) { animation-delay: 0.2s; }

/* ── Customize button style ──────────────────────── */
#dw-customize-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#dw-customize-btn svg {
    opacity: 0.7;
}
