/* ==================== ГЛОБАЛЬНІ СТИЛІ ДРІМОПОЛІЇ ==================== */

:root {
  /* Темна палітра */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --border-light: #475569;

  /* Акцентні кольори */
  --accent-gold: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;

  /* Фірмові кольори бренду DREAM */
  --dream-yellow: #FFD000;          /* Акцентний жовтий DREAM */
  --dream-yellow-hover: #E6BC00;
  --dream-black: #0F172A;           /* Глибокий чорно-синій для тексту та шапки */
  --dream-bg-dark: #0B1120;         /* Фон дашборду */
  --dream-card-bg: #FFFFFF;         /* Білі картки як на порталі */
  --dream-card-text: #0F172A;       /* Чорний текст для максимальної читабельності */
  --dream-border: #E2E8F0;
  --dream-pill-radius: 9999px;      /* Заокруглення кнопок «пігулок» */
  --dream-card-radius: 12px;        /* Заокруглення карток */
  
  /* Семафорні кольори */
  --status-success: #10b981;
  --status-warning: #facc15;
  --status-danger: #ef4444;
  --status-info: #0ea5e9;

  /* Кольори ролей */
  --role-br-edu: #e74c3c;
  --role-br-health: #3498db;
  --role-br-housing: #2ecc71;
  --role-br-security: #9b59b6;
  --role-br-env: #f39c12;
  --role-fin: #1976d2;
  --role-dep: #2ecc71;
  --role-upi: #f39c12;
  --role-ogs: #8e44ad;
  --role-mir: #d4a017;

  /* Типографія */
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-size-xs: 0.65rem;
  --font-size-sm: 0.75rem;
  --font-size-base: 0.95rem;
  --font-size-lg: 1.1rem;
  --font-size-xl: 1.35rem;
  --font-size-2xl: 1.75rem;

  /* Тінь */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* Переходи */
  --transition-fast: 0.15s ease-in-out;
  --transition-base: 0.3s ease-in-out;
  --transition-slow: 0.5s ease-in-out;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Лінійка прокрутки */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Заголовки */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5em;
}

h1 {
  font-size: var(--font-size-2xl);
}

h2 {
  font-size: var(--font-size-xl);
}

h3 {
  font-size: var(--font-size-lg);
}

/* Посилання */
a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-cyan);
  text-decoration: underline;
}

/* Кнопки */
button, .btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Первинна кнопка */
.btn-primary, button.primary {
  background-color: var(--accent-blue);
  color: white;
}

.btn-primary:hover:not(:disabled), button.primary:hover:not(:disabled) {
  background-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Вторинна кнопка */
.btn-secondary, button.secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled), button.secondary:hover:not(:disabled) {
  background-color: var(--border-light);
  border-color: var(--text-primary);
}

/* Небезпечна кнопка */
.btn-danger, button.danger {
  background-color: var(--status-danger);
  color: white;
}

.btn-danger:hover:not(:disabled), button.danger:hover:not(:disabled) {
  background-color: #dc2626;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Успішна кнопка */
.btn-success, button.success {
  background-color: var(--status-success);
  color: white;
}

.btn-success:hover:not(:disabled), button.success:hover:not(:disabled) {
  background-color: #059669;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Інпути */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Картки */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-xl);
}

/* Бейджи */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  white-space: nowrap;
}

.badge-primary {
  background-color: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: #86efac;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background-color: rgba(250, 204, 21, 0.15);
  color: #fef08a;
  border: 1px solid rgba(250, 204, 21, 0.3);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Модальні вікна */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn var(--transition-base);
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--transition-base);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Сповіщення */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid;
  margin-bottom: 16px;
  font-size: var(--font-size-sm);
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-blue);
  color: #bfdbfe;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: var(--status-success);
  color: #a7f3d0;
}

.alert-warning {
  background-color: rgba(250, 204, 21, 0.1);
  border-color: var(--status-warning);
  color: #fef3c7;
}

.alert-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: var(--status-danger);
  color: #fca5a5;
}

/* Сітка */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Flex утиліти */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-col {
  flex-direction: column;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

/* Відступи */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }

.p-2 { padding: 8px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.p-8 { padding: 32px; }

/* Текст утиліти */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

/* Анімації */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Мобільна адаптація */
@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .modal-content {
    padding: 16px;
  }
  
  button, .btn {
    padding: 8px 12px;
    font-size: var(--font-size-sm);
  }
}
