/**
 * ============================================================
 * HOSTELOS - DASHBOARD V2 STYLES
 * ============================================================
 * Modular dashboard with tenant-aware design
 *
 * Design Principles:
 * - Grid-based responsive layout
 * - Block-based architecture (each block independent)
 * - State indicators (loading, error, ok)
 * - Traffic light operational status
 *
 * @version 2.0.0
 * @contract_version 1.2
 */

/* ============================================
   CSS VARIABLES (Dashboard specific)
   ============================================ */
:root {
  /* Status colors */
  --status-normal: #27AE60;
  --status-attention: #F2C94C;
  --status-critical: #EB5757;

  /* Block states */
  --block-bg: #ffffff;
  --block-border: #e0e0e0;
  --block-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);

  /* Text */
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;

  /* Spacing */
  --gap-sm: 0.5rem;
  --gap-md: 1rem;
  --gap-lg: 1.5rem;

  /* Dashboard specific */
  --dashboard-max-width: 1400px;
  --block-radius: 8px;
}

/* ============================================
   DASHBOARD CONTAINER
   ============================================ */
.dashboard-v2 {
  max-width: var(--dashboard-max-width);
  margin: 0 auto;
  padding: var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
}

/* ============================================
   DASHBOARD HEADER
   ============================================ */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--gap-md);
  background: var(--block-bg);
  border-radius: var(--block-radius);
  box-shadow: var(--block-shadow);
}

.dashboard-header__left {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.dashboard-header__greeting {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.dashboard-header__subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.dashboard-header__right {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
}

.dashboard-header__datetime {
  text-align: right;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Operational Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-indicator--normal {
  background: rgba(39, 174, 96, 0.1);
  color: var(--status-normal);
}

.status-indicator--attention {
  background: rgba(242, 201, 76, 0.15);
  color: #9A7B00;
}

.status-indicator--critical {
  background: rgba(235, 87, 87, 0.1);
  color: var(--status-critical);
}

.status-indicator__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-indicator--normal .status-indicator__dot {
  background: var(--status-normal);
}

.status-indicator--attention .status-indicator__dot {
  background: var(--status-attention);
  animation: pulse-attention 1.5s infinite;
}

.status-indicator--critical .status-indicator__dot {
  background: var(--status-critical);
  animation: pulse-critical 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-attention {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

@keyframes pulse-critical {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions {
  display: flex;
  gap: var(--gap-md);
  flex-wrap: wrap;
  padding: var(--gap-md);
  background: var(--block-bg);
  border-radius: var(--block-radius);
  box-shadow: var(--block-shadow);
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--block-border);
  border-radius: 6px;
  background: #f8f9fa;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-action-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
}

.quick-action-btn--primary {
  background: #2D9CDB;
  border-color: #2D9CDB;
  color: white;
}

.quick-action-btn--primary:hover {
  background: #2589c5;
  border-color: #2589c5;
}

.quick-action-btn i {
  font-size: 1rem;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-lg);
}

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

/* ============================================
   DASHBOARD BLOCKS (Base)
   ============================================ */
.dashboard-block {
  background: var(--block-bg);
  border-radius: var(--block-radius);
  box-shadow: var(--block-shadow);
  padding: var(--gap-md);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.dashboard-block__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--block-border);
}

.dashboard-block__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.dashboard-block__title i {
  color: #2D9CDB;
}

.dashboard-block__content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Block States */
.dashboard-block--loading .dashboard-block__content {
  justify-content: center;
  align-items: center;
}

.dashboard-block--error {
  border: 1px solid var(--status-critical);
}

.dashboard-block--error .dashboard-block__content {
  justify-content: center;
  align-items: center;
  color: var(--status-critical);
}

/* Loading Spinner */
.block-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #2D9CDB;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.block-loading-text {
  margin-top: var(--gap-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Error State */
.block-error-icon {
  font-size: 2rem;
  margin-bottom: var(--gap-sm);
}

.block-error-message {
  font-size: 0.9rem;
  margin-bottom: var(--gap-md);
}

.block-retry-btn {
  padding: 0.5rem 1rem;
  background: var(--status-critical);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
}

.block-retry-btn:hover {
  opacity: 0.9;
}

/* ============================================
   PRIORITIES BLOCK
   ============================================ */
.priority-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.priority-item {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.75rem;
  background: #fff8e1;
  border-left: 3px solid var(--status-attention);
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
}

.priority-item--critical {
  background: #ffebee;
  border-left-color: var(--status-critical);
}

.priority-item__icon {
  font-size: 1rem;
}

.priority-item__text {
  flex: 1;
}

.priority-item__count {
  font-weight: 600;
  color: var(--text-primary);
}

.priority-item--clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.priority-item--clickable:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.priority-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
}

.priority-empty i {
  font-size: 2rem;
  margin-bottom: var(--gap-sm);
  color: var(--status-normal);
}

/* ============================================
   OPERATIONS BLOCK
   ============================================ */
.operations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-md);
}

.operation-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--gap-md);
  background: #f8f9fa;
  border-radius: 6px;
  text-align: center;
}

.operation-stat__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.operation-stat__label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: var(--gap-sm);
}

.operation-stat--arrivals .operation-stat__value {
  color: #2D9CDB;
}

.operation-stat--checkins .operation-stat__value {
  color: var(--status-normal);
}

.operation-stat--checkouts .operation-stat__value {
  color: #9B59B6;
}

.operation-stat--noshows .operation-stat__value {
  color: var(--status-critical);
}

/* ============================================
   BEDS BLOCK
   ============================================ */
.beds-summary {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.beds-chart {
  display: flex;
  gap: var(--gap-sm);
  height: 24px;
  border-radius: 12px;
  overflow: hidden;
  background: #e0e0e0;
}

.beds-chart__segment {
  height: 100%;
  transition: width 0.3s ease;
}

.beds-chart__segment--occupied {
  background: #2D9CDB;
}

.beds-chart__segment--available {
  background: var(--status-normal);
}

.beds-chart__segment--dirty {
  background: var(--status-attention);
}

.beds-chart__segment--maintenance {
  background: #9B59B6;
}

.beds-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-md);
}

.beds-legend__item {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 0.875rem;
}

.beds-legend__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.beds-legend__dot--occupied {
  background: #2D9CDB;
}

.beds-legend__dot--available {
  background: var(--status-normal);
}

.beds-legend__dot--dirty {
  background: var(--status-attention);
}

.beds-legend__dot--maintenance {
  background: #9B59B6;
}

.beds-occupancy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm);
  background: #f0f7ff;
  border-radius: 6px;
  font-size: 1rem;
}

.beds-occupancy__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2D9CDB;
}

/* Overbooking Alert */
.overbooking-alert {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.75rem;
  background: #ffebee;
  border-radius: 6px;
  color: var(--status-critical);
  font-size: 0.875rem;
}

/* ============================================
   CASHBOX BLOCK
   ============================================ */
.cashbox-summary {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.cashbox-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.cashbox-total {
  display: flex;
  flex-direction: column;
}

.cashbox-total__label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cashbox-total__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--status-normal);
}

.cashbox-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.cashbox-change--positive {
  background: rgba(39, 174, 96, 0.1);
  color: var(--status-normal);
}

.cashbox-change--negative {
  background: rgba(235, 87, 87, 0.1);
  color: var(--status-critical);
}

.cashbox-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-sm);
}

.cashbox-detail {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 0.875rem;
}

.cashbox-detail__label {
  color: var(--text-secondary);
}

.cashbox-detail__value {
  font-weight: 500;
}

.cashbox-pending {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #fff3e0;
  border-radius: 6px;
}

.cashbox-pending__label {
  color: #E67E22;
  font-size: 0.875rem;
}

.cashbox-pending__value {
  font-weight: 600;
  color: #E67E22;
}

.cashbox-pending--clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cashbox-pending--clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(230, 126, 34, 0.2);
}

/* Cashbox Alert */
.cashbox-alert {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.cashbox-alert--warning {
  background: #fff8e1;
  color: #9A7B00;
}

.cashbox-alert--danger {
  background: #ffebee;
  color: var(--status-critical);
}

.cashbox-alert--clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cashbox-alert--clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================
   KPIS BLOCK
   ============================================ */
.kpis-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-md);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  padding: var(--gap-md);
  background: #f8f9fa;
  border-radius: 6px;
}

.kpi-card__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--gap-sm) 0;
}

.kpi-card__delta {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-card__delta--positive {
  color: var(--status-normal);
}

.kpi-card__delta--negative {
  color: var(--status-critical);
}

/* ============================================
   STAFF BLOCK
   ============================================ */
.staff-summary {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.staff-count {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
}

.staff-count__number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.staff-count__label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.staff-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.staff-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 4px;
}

.staff-item__name {
  font-weight: 500;
}

.staff-item__role {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.staff-item__tasks {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--status-attention);
}

/* Alerts */
.alerts-section {
  margin-top: var(--gap-md);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--block-border);
}

.alerts-section__title {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: var(--gap-sm);
}

.alert-item {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 0.5rem;
  background: #fff8e1;
  border-radius: 4px;
  font-size: 0.875rem;
  margin-bottom: var(--gap-sm);
}

.alert-item--warning {
  background: #fff8e1;
  color: #9A7B00;
}

/* ============================================
   OPERATIONAL STATUS REASONS
   ============================================ */
.status-reasons {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--gap-sm);
  padding: var(--gap-md);
  background: white;
  border-radius: var(--block-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  min-width: 300px;
}

/* Show on hover OR when visible class is added via JS click */
.status-indicator:hover .status-reasons,
.status-indicator:focus .status-reasons,
.status-reasons--visible {
  display: block !important;
}

.status-reason {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-sm);
  padding: var(--gap-sm);
  margin-bottom: var(--gap-sm);
  border-radius: 4px;
}

.status-reason--attention {
  background: #fff8e1;
}

.status-reason--critical {
  background: #ffebee;
}

.status-reason__icon {
  font-size: 1rem;
}

.status-reason__text {
  flex: 1;
  font-size: 0.875rem;
}

.status-reason__link {
  font-size: 0.75rem;
  color: #2D9CDB;
  text-decoration: none;
}

.status-reason__link:hover {
  text-decoration: underline;
}

/* Clickable status reasons */
.status-reason {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.status-reason:hover {
  transform: translateX(4px);
}

.status-reason--attention:hover {
  background: #fff3cd;
}

.status-reason--critical:hover {
  background: #f8d7da;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
  .dashboard-v2 {
    padding: var(--gap-md);
  }

  .dashboard-header {
    flex-direction: column;
    gap: var(--gap-md);
    text-align: center;
  }

  .dashboard-header__right {
    flex-direction: column;
  }

  .quick-actions {
    justify-content: center;
  }

  .operations-grid,
  .kpis-grid,
  .cashbox-details {
    grid-template-columns: 1fr;
  }

  .cashbox-main {
    flex-direction: column;
    gap: var(--gap-md);
  }

  .beds-legend {
    justify-content: center;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-muted {
  color: var(--text-muted);
}

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

.mt-auto {
  margin-top: auto;
}

.hidden {
  display: none !important;
}

/* ============================================
   SPEC v2.0: WIDE BLOCKS (Full width)
   ============================================ */
.dashboard-block--wide {
  grid-column: span 2;
}

@media (max-width: 1024px) {
  .dashboard-block--wide {
    grid-column: span 1;
  }
}

/* ============================================
   SPEC v2.0: CALENDAR BLOCK
   ============================================ */
.calendar-summary {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.calendar-date {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--block-border);
}

.calendar-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.calendar-section__header {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.calendar-section__header i {
  font-size: 0.85rem;
}

.calendar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
}

.calendar-item--arrival {
  border-left-color: #27ae60;
}

.calendar-item--departure {
  border-left-color: #e74c3c;
}

.calendar-item--done {
  opacity: 0.6;
  text-decoration: line-through;
}

.calendar-item__name {
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-item__details {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.calendar-item__bed {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 2px 6px;
  background: #e9ecef;
  border-radius: 3px;
}

.calendar-item__badge {
  color: var(--status-normal);
  font-weight: 600;
}

.calendar-more {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.5rem;
  font-style: italic;
}

.calendar-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
  margin: 0;
}

/* ============================================
   SPEC v2.0: REVENUE CHART BLOCK
   ============================================ */
#revenue-chart-content {
  position: relative;
  min-height: 180px;
}

#revenueChart {
  width: 100% !important;
  height: 160px !important;
}

.chart-total {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm) var(--gap-md);
  background: linear-gradient(135deg, #f0f7ff, #e3f2fd);
  border-radius: 6px;
  margin-top: var(--gap-md);
}

.chart-total__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.chart-total__value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2D9CDB;
}

/* ============================================
   SPEC v2.0: ACTIVITY FEED BLOCK
   ============================================ */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  max-height: 300px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-sm);
  padding: var(--gap-sm);
  border-radius: 6px;
  transition: background 0.15s ease;
}

.activity-item:hover {
  background: #f8f9fa;
}

.activity-item__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
  font-size: 0.7rem;
}

.activity-item__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.activity-item__text {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.activity-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.activity-item__user {
  font-weight: 500;
  color: var(--text-secondary);
}

.activity-item__time {
  color: var(--text-muted);
}

.activity-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: var(--gap-lg);
}

.activity-empty p {
  margin-top: var(--gap-sm);
}

/* Activity Feed Scrollbar */
.activity-feed::-webkit-scrollbar {
  width: 6px;
}

.activity-feed::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.activity-feed::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.activity-feed::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}
