/* Apptuando Meta-ERP - Admin Interface CSS */
/* Modular CSS Architecture - Mobile-first responsive design */

/* === BASE LAYER === */
/* Foundational styles and CSS custom properties */
@import url('./base/variables.css');
@import url('./base/reset.css');
@import url('./base/typography.css');

/* === LAYOUT LAYER === */
/* Grid system and layout components */
@import url('./layout/grid.css');
@import url('./layout/header.css');
@import url('./layout/sidebar.css');
@import url('./layout/main.css');

/* === COMPONENTS LAYER === */
/* UI components and interactive elements */
@import url('./components/buttons.css');
@import url('./components/forms.css');
@import url('./components/cards.css');
@import url('./components/tables.css');

/* === UTILITIES LAYER === */
/* Utility classes for spacing, colors, and responsive behavior */
@import url('./utilities/spacing.css');

/* === LEGACY COMPATIBILITY === */
/* Temporary compatibility styles for existing templates */
/* TODO: Remove these as templates are migrated to use modular components */

/* Main layout structure using CSS Grid */
.admin-layout {
  min-height: 100vh;
  background: var(--surface-secondary);
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  grid-template-areas: 
    "header"
    "main";
}

/* Mobile: Stack vertically */
.admin-header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.admin-sidebar {
  display: none; /* Hidden on mobile by default */
}

/* Mobile sidebar toggle */
.admin-sidebar.open {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1050;
  background: var(--surface);
}

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
  display: none;
}

.sidebar-overlay.show {
  display: block;
}

.admin-main {
  grid-area: main;
  min-height: 0; /* Allow grid to control height */
  overflow-y: auto; /* Allow scrolling */
}

.admin-main-content {
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-2); /* Minimal left padding */
  max-width: none;
  margin: 0;
}

/* Desktop: Grid layout with sidebar */
@media (min-width: 768px) {
  .admin-layout {
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas: 
      "sidebar header"
      "sidebar main";
  }
  
  .admin-sidebar {
    display: block;
    grid-area: sidebar;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  
  .admin-header {
    grid-area: header;
  }
  
  .admin-main {
    grid-area: main;
  }
  
  .admin-main-content {
    padding: var(--space-6) var(--space-6) var(--space-6) var(--space-2); /* Minimal left padding */
  }
}

/* Large desktop adjustments */
@media (min-width: 1024px) {
  .admin-main-content {
    padding: var(--space-8) var(--space-8) var(--space-8) var(--space-2); /* Minimal left padding */
  }
}

/* Page styling */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-6);
}

.page-title {
  margin: 0;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text);
  line-height: 1.2;
}

/* Status indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-secondary);
}

.status-pending { color: var(--warning); background: var(--warning-light); }
.status-installing { color: var(--info); background: var(--info-light); }
.status-running { color: var(--success); background: var(--success-light); }
.status-failed { color: var(--danger); background: var(--danger-light); }
.status-stopped { color: var(--secondary); background: var(--surface-tertiary); }

/* Badges */
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  color: var(--text-light);
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--radius-sm);
}

.badge-primary { background-color: var(--primary); }
.badge-secondary { background-color: var(--secondary); }
.badge-success { background-color: var(--success); }
.badge-danger { background-color: var(--danger); }
.badge-warning { background-color: var(--warning); color: var(--text); }
.badge-info { background-color: var(--info); }
.badge-light { background-color: var(--surface-tertiary); color: var(--text); }
.badge-dark { background-color: var(--text); }

/* Bootstrap compatibility classes */
.bg-primary { background-color: var(--primary) !important; }
.bg-secondary { background-color: var(--secondary) !important; }
.bg-success { background-color: var(--success) !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-warning { background-color: var(--warning) !important; }
.bg-info { background-color: var(--info) !important; }
.bg-light { background-color: var(--surface) !important; }
.bg-dark { background-color: var(--text) !important; }

/* Border utilities */
.border { border: 1px solid var(--border) !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid var(--border) !important; }
.border-right { border-right: 1px solid var(--border) !important; }
.border-bottom { border-bottom: 1px solid var(--border) !important; }
.border-left { border-left: 1px solid var(--border) !important; }

.border-primary { border-color: var(--primary) !important; }
.border-secondary { border-color: var(--secondary) !important; }
.border-success { border-color: var(--success) !important; }
.border-danger { border-color: var(--danger) !important; }
.border-warning { border-color: var(--warning) !important; }
.border-info { border-color: var(--info) !important; }
.border-light { border-color: var(--border-light) !important; }
.border-dark { border-color: var(--border-dark) !important; }

/* Rounded corners */
.rounded { border-radius: var(--radius) !important; }
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }
.rounded-0 { border-radius: 0 !important; }

/* Shadow utilities */
.shadow-none { box-shadow: none !important; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.shadow-xl { box-shadow: var(--shadow-xl) !important; }

/* Width and height utilities */
.w-25 { width: 25% !important; }
.w-50 { width: 50% !important; }
.w-75 { width: 75% !important; }
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }

.h-25 { height: 25% !important; }
.h-50 { height: 50% !important; }
.h-75 { height: 75% !important; }
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }

.mw-100 { max-width: 100% !important; }
.mh-100 { max-height: 100% !important; }

/* Position utilities */
.position-static { position: static !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }

/* Overflow utilities */
.overflow-auto { overflow: auto !important; }
.overflow-hidden { overflow: hidden !important; }
.overflow-visible { overflow: visible !important; }
.overflow-scroll { overflow: scroll !important; }

/* Text utilities (additional to typography.css) */
.text-break { word-wrap: break-word !important; word-break: break-word !important; }
.text-decoration-none { text-decoration: none !important; }
.text-decoration-underline { text-decoration: underline !important; }

/* Visibility utilities */
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }

/* Legacy alert styles (for existing templates) */
.alert {
  position: relative;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.alert-primary {
  color: var(--primary-700);
  background-color: var(--primary-50);
  border-color: var(--primary-100);
}

.alert-secondary {
  color: var(--text);
  background-color: var(--surface-tertiary);
  border-color: var(--border);
}

.alert-success {
  color: #065f46;
  background-color: #d1fae5;
  border-color: #a7f3d0;
}

.alert-danger {
  color: #991b1b;
  background-color: #fee2e2;
  border-color: #fecaca;
}

.alert-warning {
  color: #92400e;
  background-color: #fef3c7;
  border-color: #fde68a;
}

.alert-info {
  color: #155e75;
  background-color: #cffafe;
  border-color: #a5f3fc;
}

/* Print styles */
@media print {
  .admin-sidebar,
  .admin-header,
  .mobile-menu-toggle,
  .sidebar-overlay {
    display: none !important;
  }
  
  .admin-main {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 0 !important;
  }
  
  .card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  
  .btn {
    border: 1px solid #000 !important;
  }
}