* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed: 70px;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #0f3460;
  --primary: #e94560;
  --text-light: #eaeaea;
  --text-muted: #a0a0b0;
  --topbar-bg: #ffffff;
  --content-bg: #f0f2f5;
  --shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--content-bg);
  overflow: hidden;
}

/* Ensure iframe child pages fill the frame */
body:has(.page-content) {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  overflow: hidden;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
}

.logo i {
  font-size: 24px;
  color: var(--primary);
  flex-shrink: 0;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar.collapsed .toggle-btn {
  transform: rotate(180deg);
}

/* Nav list */
.nav-list {
  list-style: none;
  padding: 10px 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--text-light);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: var(--text-light);
  border-left-color: var(--primary);
}

.nav-link i {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-text {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-footer {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-footer {
  padding: 15px;
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 25px;
  background: var(--topbar-bg);
  box-shadow: var(--shadow);
  z-index: 10;
  min-height: 60px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 600;
  color: #333;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #555;
  font-size: 14px;
}

.user-info i {
  font-size: 28px;
  color: var(--primary);
}

.content {
  flex: 1;
  padding: 0;
  overflow: hidden;
}

#pageFrame {
  width: 100%;
  height: 100%;
  border: none;
}

/* Page content styles (used in iframe pages) */
.page-content {
  padding: 25px;
  height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.page-content h2 {
  font-size: 24px;
  color: #333;
  margin-bottom: 20px;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 10px;
}

.card p {
  color: #666;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-card i {
  font-size: 36px;
  color: var(--primary);
}

.stat-card-expired i {
  color: #dc3545;
}

.stat-card-expired .stat-info span {
  color: #dc3545;
}

.stat-info h4 {
  font-size: 14px;
  color: #888;
  font-weight: 400;
}

.stat-info span {
  font-size: 28px;
  font-weight: 700;
  color: #333;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h2 {
  margin-bottom: 0;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #d63850;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #ccc;
}

/* Table */
.table-wrapper {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead {
  background: var(--sidebar-bg);
  color: var(--text-light);
}

.data-table th {
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 15px;
  border-bottom: 1px solid #eee;
  color: #444;
}

.data-table tbody tr:hover {
  background: #f8f9fa;
}

.data-table tbody tr.row-expired {
  background: #fff0f0;
}

.data-table tbody tr.row-expired:hover {
  background: #ffe0e0;
}

.data-table tbody tr.row-warning {
  background: #fff8e1;
}

.data-table tbody tr.row-warning:hover {
  background: #fff3c4;
}

.data-table tbody tr.row-conservare {
  background: #fff9c4;
}

.data-table tbody tr.row-conservare:hover {
  background: #fff176;
}

.data-table tbody tr.row-casat {
  background: #c8e6c9;
}

.data-table tbody tr.row-casat:hover {
  background: #a5d6a7;
}

.data-table tbody tr.row-instrainat {
  background: #e0e0e0;
}

.data-table tbody tr.row-instrainat:hover {
  background: #bdbdbd;
}

.data-table tbody tr.row-in-curs {
  background: #fff3e0;
}

.data-table tbody tr.row-in-curs:hover {
  background: #ffe0b2;
}

.zile-cell {
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.badge-expired {
  background: var(--primary);
  color: #fff;
}

.actions-cell {
  white-space: nowrap;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 16px;
  transition: background 0.2s;
}

.btn-edit {
  color: #1976d2;
}

.btn-edit:hover {
  background: #e3f2fd;
}

.btn-delete {
  color: var(--primary);
}

.btn-delete:hover {
  background: #ffebee;
}

.btn-map {
  color: #2e7d32;
}

.btn-map:hover {
  background: #e8f5e9;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 25px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #888;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-form {
  padding: 25px;
}

#instalatieForm {
  padding: 25px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.form-group input {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.15);
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 8px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #444;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

/* Filters bar */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

.filter-group select,
.filter-group input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  min-width: 180px;
  background: #fff;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Expand rows */
.expand-row td {
  padding: 0;
  background: #fafbfc;
  border-bottom: 2px solid #e0e0e0;
}

.expand-content {
  padding: 15px 25px;
}

.expand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  font-size: 14px;
  color: #444;
}

.firma-nume {
  color: var(--sidebar-active);
  text-decoration: none;
  cursor: pointer;
}

.firma-nume:hover {
  text-decoration: underline;
  color: var(--primary);
}

/* Chart */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 15px;
  font-size: 14px;
  color: #555;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100%;
    width: var(--sidebar-width);
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .sidebar.collapsed .nav-text,
  .sidebar.collapsed .logo-text,
  .sidebar.collapsed .sidebar-footer {
    opacity: 1;
    width: auto;
    overflow: visible;
  }

  .sidebar .toggle-btn {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    padding: 10px 15px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
  }

  .user-info span {
    display: none;
  }

  .page-content {
    padding: 15px;
  }

  .page-content h2 {
    font-size: 18px;
    margin-bottom: 15px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .page-header > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-header .btn {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 8px 12px;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
    gap: 10px;
  }

  .stat-card i {
    font-size: 24px;
  }

  .stat-info span {
    font-size: 20px;
  }

  .stat-info h4 {
    font-size: 12px;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filter-group select,
  .filter-group input {
    min-width: 0;
    width: 100%;
  }

  .table-wrapper {
    overflow-x: auto;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  .actions-cell .btn-icon {
    padding: 4px 6px;
    font-size: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal {
    width: 95%;
    max-width: 95%;
    margin: 10px;
  }

  .modal-header {
    padding: 15px;
  }

  .modal-form {
    padding: 15px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .checkbox-group {
    flex-direction: column;
    gap: 6px;
  }

  .expand-grid {
    grid-template-columns: 1fr;
  }

  .expand-content {
    padding: 10px 15px;
  }

  .chart-container {
    height: 200px;
  }

  .chart-legend {
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
  }

  .harta-container {
    margin: 8px 10px 10px;
  }

  .harta-status {
    font-size: 11px;
    padding: 6px 10px;
    top: 10px;
    left: 10px;
  }

  .harta-legend {
    font-size: 11px;
    padding: 6px 10px;
    bottom: 20px;
    right: 10px;
  }

  .plasare-panel {
    width: calc(100% - 20px);
    right: 10px;
    top: 50px;
  }

  .admin-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 5px;
  }

  .admin-tabs .tab-btn {
    flex-shrink: 0;
    font-size: 12px;
    padding: 8px 14px;
  }

  .admin-section .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .abonament-actions {
    flex-direction: column;
  }

  .log-entry {
    font-size: 12px;
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  .page-content {
    padding: 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-card i {
    font-size: 20px;
  }

  .stat-info span {
    font-size: 18px;
  }

  .data-table {
    font-size: 11px;
  }

  .data-table th,
  .data-table td {
    padding: 6px 8px;
  }

  .page-header .btn {
    font-size: 12px;
    padding: 6px 10px;
  }

  .btn {
    font-size: 12px;
    padding: 8px 14px;
  }

  .modal-header h3 {
    font-size: 15px;
  }

  .topbar h1 {
    font-size: 14px;
  }

  .harta-container {
    margin: 5px 5px 5px;
    border-radius: 4px;
  }

  .plasare-panel {
    padding: 12px;
    font-size: 12px;
  }

  .plasare-panel select {
    font-size: 12px;
    padding: 6px 8px;
  }
}
