/* =========================================================
   Smart Duty Map Module — map-module.css
   ========================================================= */

/* ---- Container ---- */
.map-module-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 600px;
    overflow: hidden;
}

/* ---- Toolbar ---- */
.map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 16px;
    padding: 10px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0; /* never shrink — gives more space to canvas */
}

.map-toolbar-right, .map-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Floor selector */
.map-floor-selector {
    display: flex;
    gap: 6px;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 12px;
}

.map-floor-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    background: transparent;
    color: #64748b;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: inherit;
}

.map-floor-btn.active {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
    box-shadow: 0 4px 12px rgba(6,182,212,0.35);
}

.map-floor-btn:hover:not(.active) {
    background: #e2e8f0;
    color: #0891b2;
}

/* Upload */
.map-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: #0891b2;
    border: 2px dashed #06b6d4;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
}

.map-upload-btn:hover {
    background: #ecfeff;
    border-color: #0891b2;
    transform: translateY(-1px);
}

.map-upload-btn.large {
    padding: 14px 30px;
    font-size: 1rem;
    border-radius: 16px;
    margin-top: 16px;
}

/* Tool buttons */
.map-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: #eff6ff;
    color: #2563eb;
    font-family: inherit;
}

.map-tool-btn:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

.map-tool-btn.active-mode {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 4px 12px rgba(245,158,11,0.4);
}

.map-tool-btn.danger {
    background: #fee2e2;
    color: #ef4444;
}

.map-tool-btn.danger:hover {
    background: #fecaca;
}

.map-tool-btn.success {
    background: #dcfce7;
    color: #16a34a;
}

.map-tool-btn.success:hover {
    background: #bbf7d0;
}

/* Legend */
.map-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
}

.map-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.map-legend-dot.covered {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.7);
}

.map-legend-dot.vacant {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239,68,68,0.7);
}

/* ---- Canvas Wrap ---- */
.map-canvas-wrap {
    display: flex;
    gap: 14px;
    flex: 1;
    min-height: 0;   /* critical: don't grow outside flex parent */
    overflow: hidden;
}

/* ---- Map Canvas ---- */
.map-canvas {
    flex: 1;
    position: relative;
    background: #f8fafc;
    border-radius: 18px;
    border: 2px solid #e2e8f0;
    overflow: auto;
    cursor: default;
    transition: border-color 0.2s;
    /* Stretch image to full width — no side gaps */
    height: 100%;
}

.map-canvas.edit-mode {
    cursor: crosshair;
    border-color: #f59e0b;
    border-style: dashed;
}

/* Placeholder */
.map-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #94a3b8;
    text-align: center;
    padding: 40px;
    z-index: 2;
}

.map-placeholder i {
    font-size: 5rem;
    color: #e2e8f0;
    margin-bottom: 10px;
}

.map-placeholder h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #475569;
}

.map-placeholder p {
    margin: 0;
    font-size: 0.9rem;
}

/* ---- Anchor Pins ---- */
.map-anchor {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.2s;
}

.map-anchor:hover {
    transform: translate(-50%, -100%) scale(1.1);
    z-index: 20;
}

@keyframes anchorFloat {
    0%, 100% { margin-top: 0; }
    50% { margin-top: -5px; }
}

.map-anchor {
    animation: anchorFloat 3s ease-in-out infinite;
}

.map-anchor-bubble {
    background: rgba(15, 23, 42, 0.95);
    color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 8px 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    white-space: nowrap;
    text-align: center;
    border: 2px solid rgba(255,255,255,0.1);
    min-width: 100px;
    position: relative;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.map-anchor-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid rgba(15, 23, 42, 0.95);
}

/* Covered state */
.map-anchor.covered .map-anchor-bubble {
    border-color: #22c55e;
    box-shadow: 0 6px 20px rgba(34,197,94,0.2), 0 0 0 3px rgba(34,197,94,0.15);
}

.map-anchor.covered .map-anchor-bubble::after {
    border-top: 10px solid #22c55e;
}

/* Vacant state */
.map-anchor.vacant .map-anchor-bubble {
    border-color: #ef4444;
    box-shadow: 0 6px 20px rgba(239,68,68,0.2), 0 0 0 3px rgba(239,68,68,0.15);
    animation: pulseRed 2s infinite;
}

.map-anchor.vacant .map-anchor-bubble::after {
    border-top: 10px solid #ef4444;
}

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 6px 20px rgba(239,68,68,0.2), 0 0 0 3px rgba(239,68,68,0.15); }
    50% { box-shadow: 0 6px 20px rgba(239,68,68,0.35), 0 0 0 6px rgba(239,68,68,0.08); }
}

.map-anchor-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.6);
    line-height: 1;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
 
.map-anchor-teacher {
    font-size: 0.85rem;
    font-weight: 800;
    color: white;
    line-height: 1.2;
}
 
.map-anchor-teacher.empty {
    color: #f87171;
    font-style: italic;
    opacity: 0.9;
}

.map-anchor-actions {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 6px;
    flex-direction: column;
    gap: 4px;
    z-index: 30;
    min-width: 140px;
    border: 1px solid #f1f5f9;
}

.map-anchor:hover .map-anchor-actions {
    display: flex;
}

.anchor-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    background: #f8fafc;
    color: #334155;
    width: 100%;
    text-align: right;
    transition: background 0.15s;
    font-family: inherit;
}

.anchor-action-btn:hover {
    background: #eff6ff;
    color: #2563eb;
}

.anchor-action-btn.danger:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ---- Sidebar ---- */
.map-sidebar {
    width: 210px;
    flex-shrink: 0;
    background: white;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;  /* no outer scroll */
    height: 100%;      /* fill parent flex height exactly */
    box-sizing: border-box;
}

.map-sidebar h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-stats-bar {
    background: #f1f5f9;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    text-align: center;
}

.map-stats-bar span {
    font-size: 1.1rem;
    font-weight: 900;
    color: #0f172a;
}

.map-teacher-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-teacher-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    cursor: grab;
    transition: all 0.2s;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e293b;
}

.map-teacher-chip:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateX(-2px);
}

.map-teacher-chip.assigned {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.map-teacher-chip .teacher-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}

.map-teacher-chip.assigned .teacher-dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.6);
}

/* ---- Edit Hint ---- */
.map-edit-hint {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeInDown 0.3s ease-out;
}

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

/* Hover tooltip for teacher workload on anchor */
.anchor-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 40;
}

.map-anchor:hover .anchor-tooltip {
    opacity: 1;
}

/* Print styles */
@media print {
    .map-toolbar, .map-sidebar { display: none !important; }
    .map-canvas-wrap { gap: 0 !important; }
    .map-canvas { border: none !important; }
}

/* =============================================
   Premium Map Navigation Tab
   ============================================= */
.sub-nav-tab.map-nav-tab {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sub-nav-tab.map-nav-tab i {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.sub-nav-tab.map-nav-tab i::before {
    background: none !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.sub-nav-tab.map-nav-tab:hover:not(.active) {
    transform: translateY(-2.5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.45);
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%) !important;
}

/* عند الضغط — أبيض مع نص رمادي */
.sub-nav-tab.map-nav-tab.active {
    background: #ffffff !important;
    color: #94a3b8 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1), inset 0 1px 3px rgba(0,0,0,0.05) !important;
    border: 1px solid #e2e8f0 !important;
    transform: translateY(0) !important;
}

.sub-nav-tab.map-nav-tab.active i {
    background: rgba(100, 116, 139, 0.1) !important;
    color: #94a3b8 !important;
    box-shadow: none !important;
    border: none !important;
}

.sub-nav-tab.map-nav-tab.active i::before {
    -webkit-text-fill-color: #94a3b8 !important;
    text-shadow: none !important;
}

/* Icon floating effect */
.sub-nav-tab.map-nav-tab i {
    animation: mapIconFloat 3s ease-in-out infinite;
}

@keyframes mapIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ---- Zoom Controls ---- */
.map-zoom-ctrl {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.map-zoom-ctrl button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-zoom-ctrl button:hover {
    background: #f8fafc;
    color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.map-zoom-ctrl button:active {
    transform: scale(0.95);
}



/* =============================================
   Exam Navigation Tab
   ============================================= */
.sub-nav-tab.exam-nav-tab {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sub-nav-tab.exam-nav-tab i {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.sub-nav-tab.exam-nav-tab i::before {
    background: none !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.sub-nav-tab.exam-nav-tab:hover:not(.active) {
    transform: translateY(-2.5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.45);
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important;
}

.sub-nav-tab.exam-nav-tab.active {
    background: #ffffff !important;
    color: #94a3b8 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1), inset 0 1px 3px rgba(0,0,0,0.05) !important;
    border: 1px solid #e2e8f0 !important;
    transform: translateY(0) !important;
}

.sub-nav-tab.exam-nav-tab.active i {
    background: rgba(100, 116, 139, 0.1) !important;
    color: #94a3b8 !important;
}

.sub-nav-tab.exam-nav-tab.active i::before {
    -webkit-text-fill-color: #94a3b8 !important;
}


/* =========================================================
   Exam Map Specific Styles
   ========================================================= */
.exam-map-anchor {
    position: absolute;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.2s;
    animation: anchorFloat 3s ease-in-out infinite;
}
.exam-map-anchor:hover {
    transform: translate(-50%, -100%) scale(1.1);
    z-index: 20;
}
.exam-map-anchor-bubble {
    background: rgba(15, 23, 42, 0.95);
    color: white;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 8px 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    white-space: nowrap;
    text-align: center;
    border: 2px solid rgba(255,255,255,0.1);
    min-width: 100px;
    position: relative;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.exam-map-anchor-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid rgba(15, 23, 42, 0.95);
}
.exam-map-anchor.covered .exam-map-anchor-bubble {
    border-color: #22c55e;
    box-shadow: 0 6px 20px rgba(34,197,94,0.2), 0 0 0 3px rgba(34,197,94,0.15);
}
.exam-map-anchor.covered .exam-map-anchor-bubble::after {
    border-top: 10px solid #22c55e;
}
.exam-map-anchor.vacant .exam-map-anchor-bubble {
    border-color: #ef4444;
    box-shadow: 0 6px 20px rgba(239,68,68,0.2), 0 0 0 3px rgba(239,68,68,0.15);
    animation: pulseRed 2s infinite;
}
.exam-map-anchor.vacant .exam-map-anchor-bubble::after {
    border-top: 10px solid #ef4444;
}
.exam-map-anchor-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255,255,255,0.6);
    line-height: 1;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.exam-map-anchor-teacher {
    font-size: 0.85rem;
    font-weight: 800;
    color: white;
    line-height: 1.2;
}
.exam-map-anchor-teacher.empty {
    color: #f87171;
    font-style: italic;
    opacity: 0.9;
}
.exam-map-anchor-actions {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 6px;
    flex-direction: column;
    gap: 4px;
    z-index: 30;
    min-width: 140px;
    border: 1px solid #f1f5f9;
}
.exam-map-anchor:hover .exam-map-anchor-actions {
    display: flex;
}
