
/* File: app/static/css/layout.css */

html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: #f5f7fa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: relative;
}

.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.content {
  flex: 1;
}

/* ============================================ */
/* BOOTSTRAP CONTAINER OVERRIDE */
/* ============================================ */

.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  max-width: 1400px !important; /* ~20% wider than default 1200px */
}

/* ============================================ */
/* TABLE LAYOUT - PREVENT JUMPING */
/* ============================================ */

.table-responsive table {
  table-layout: fixed;
  width: 100%;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================ */
/* NAVBAR - Modern Clean Design */
/* ============================================ */

.navbar-custom {
  background: var(--bg-dark);
  padding: 0;
  position: relative;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.navbar-custom > .container {
  display: flex;
  align-items: stretch;
  min-height: 64px;
}

/* Brand */
.navbar-brand {
  color: var(--text-white) !important;
  font-weight: 700;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 1rem;
  margin: 0;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.navbar-brand:hover {
  opacity: 0.9;
}

.navbar-logo-icon {
  height: 32px;
  width: auto;
}

.brand-text {
  background: linear-gradient(135deg, var(--text-white) 0%, var(--ps-light-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Nav container */
.navbar-collapse {
  display: flex;
  align-items: stretch;
}

.navbar-nav {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
}

/* Nav Links */
.nav-link {
  color: var(--text-light) !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0 1rem !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
  position: relative;
  height: 100%;
  min-height: 64px;
  border: none;
  background: transparent;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--ps-light-blue);
  transition: width var(--transition-fast);
  border-radius: 2px 2px 0 0;
}

.nav-link:hover {
  color: var(--text-white) !important;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link:hover::after {
  width: calc(100% - 1rem);
}

/* Nav icons */
.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.nav-link:hover .nav-icon {
  opacity: 1;
}

/* Active state */
.nav-item .nav-link.active,
.nav-item .nav-link[aria-current="page"] {
  color: var(--text-white) !important;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item .nav-link.active::after {
  width: calc(100% - 1rem);
  background: var(--ps-teal);
}

.nav-item .nav-link.active .nav-icon {
  opacity: 1;
  color: var(--ps-teal);
}

/* Dropdown Toggle - hide default caret */
.nav-link.dropdown-toggle::after {
  display: inline-block;
  margin-left: 0.375rem;
  vertical-align: middle;
  content: "";
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
  opacity: 0.6;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav-link.dropdown-toggle:hover::after {
  opacity: 1;
}

.dropdown.show .nav-link.dropdown-toggle::after {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown-menu-custom {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 200px;
  margin-top: 0 !important;
  animation: dropdownFadeIn 0.15s ease-out;
}

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

.dropdown-menu-custom .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.dropdown-menu-custom .dropdown-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.6;
  flex-shrink: 0;
}

.dropdown-menu-custom .dropdown-item:hover {
  background: var(--bg-muted);
  color: var(--ps-blue);
}

.dropdown-menu-custom .dropdown-item:hover svg {
  opacity: 1;
  color: var(--ps-blue);
}

.dropdown-menu-custom .dropdown-item.active {
  background: rgba(0, 100, 162, 0.08);
  color: var(--ps-blue);
}

.dropdown-menu-custom .dropdown-item.active svg {
  opacity: 1;
  color: var(--ps-blue);
}

.dropdown-menu-custom .dropdown-divider {
  margin: 0.375rem 0;
  border-color: var(--border-light);
}

.dropdown-menu-custom .dropdown-item.text-danger {
  color: var(--color-danger);
}

.dropdown-menu-custom .dropdown-item.text-danger:hover {
  background: rgba(220, 53, 69, 0.08);
  color: var(--color-danger);
}

.dropdown-menu-custom .dropdown-item.text-danger svg {
  color: var(--color-danger);
}

/* Navbar Toggle for mobile */
.navbar-toggler {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  transition: all var(--transition-fast);
}

.navbar-toggler:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.navbar-toggler:focus {
  box-shadow: none;
}

.navbar-toggler-icon {
  filter: brightness(0) invert(1);
  width: 1.25rem;
  height: 1.25rem;
}

/* Public Site link - distinct styling */
.nav-link-public {
  background: rgba(117, 255, 219, 0.1) !important;
  border-radius: var(--radius-md);
  margin: 0.75rem 0.25rem;
  min-height: auto !important;
  padding: 0.5rem 0.875rem !important;
  border: 1px solid rgba(117, 255, 219, 0.2);
}

.nav-link-public:hover {
  background: rgba(117, 255, 219, 0.2) !important;
  border-color: rgba(117, 255, 219, 0.4);
}

.nav-link-public .nav-icon {
  color: var(--ps-teal);
  opacity: 1;
}

.nav-link-public::after {
  display: none !important;
}

/* User account nav item - special styling */
.nav-item:last-child .nav-link {
  margin-left: 0.5rem;
  padding-left: 0.75rem !important;
  padding-right: 0.75rem !important;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* Footer */
.footer {
  background: var(--bg-dark);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-logo {
  color: var(--text-white);
  font-weight: 600;
  font-size: 0.9rem;
}

.footer-version {
  background: rgba(117, 255, 219, 0.15);
  color: var(--ps-teal);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--text-white);
}

.footer-link svg {
  opacity: 0.7;
}

.footer-link:hover svg {
  opacity: 1;
}

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

@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    order: -1;
  }
}

/* ============================================ */
/* RESPONSIVE DESIGN */
/* ============================================ */

/* Tablet-friendly adjustments (768px - 1024px) */
@media (max-width: 1024px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-compact th {
    padding: 0.6rem 0.4rem;
    font-size: 0.8rem;
  }

  .table-compact td {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
  }

  .action-buttons {
    gap: 0.2rem;
  }

  .btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
  }

  .section-summary {
    gap: 1rem;
    font-size: 0.8rem;
  }
}

/* Mobile adjustments (max 767px) */
@media (max-width: 767px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-compact {
    font-size: 0.75rem;
    display: block;
    width: 100%;
    border-collapse: collapse;
  }

  .table-compact thead {
    display: none;
  }

  .table-compact tbody {
    display: block;
    width: 100%;
  }

  .table-compact tbody tr {
    display: block;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem;
    background: white;
  }

  .table-compact tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border: none;
    border-bottom: 1px solid #f1f5f9;
  }

  .table-compact tbody td:last-child {
    border-bottom: none;
  }

  .table-compact tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #666;
    flex: 0 0 40%;
  }

  /* Add data-label attributes in HTML: data-label="Device", data-label="IP", etc. */
  .table-compact tbody td:nth-child(1)::before { content: "Device"; }
  .table-compact tbody td:nth-child(2)::before { content: "IP"; }
  .table-compact tbody td:nth-child(3)::before { content: "Status"; }
  .table-compact tbody td:nth-child(4)::before { content: "Channel"; }
  .table-compact tbody td:nth-child(5)::before { content: "Location"; }
  .table-compact tbody td:nth-child(6)::before { content: "Version"; }
  .table-compact tbody td:nth-child(7)::before { content: "Resolution"; }
  .table-compact tbody td:nth-child(8)::before { content: "Orientation"; }
  .table-compact tbody td:nth-child(9)::before { content: "Uptime"; }
  .table-compact tbody td:nth-child(10)::before { content: "CPU Temp"; }
  .table-compact tbody td:nth-child(11)::before { content: "Memory"; }
  .table-compact tbody td:nth-child(12)::before { content: "Actions"; }

  .action-buttons {
    gap: 0.3rem;
    width: 100%;
    justify-content: flex-end;
  }

  .btn-xs {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
  }

  .section-header td {
    padding: 0.75rem 0.5rem;
  }

  .section-summary {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    font-size: 0.75rem;
  }

  .section-title {
    font-size: 0.85rem;
  }

  .code-sm {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .search-input {
    width: 100%;
    max-width: 200px;
  }

  .btn-group-sm {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}

/* Extra small devices (max 480px) */
@media (max-width: 480px) {
  .navbar-custom > .container {
    min-height: 56px;
  }

  .navbar-brand {
    padding: 0 0.5rem;
    font-size: 1rem;
  }

  .navbar-logo-icon {
    height: 26px;
  }

  .nav-link {
    padding: 0.75rem 1rem !important;
    min-height: auto;
    font-size: 0.875rem;
  }

  .nav-link::after {
    display: none;
  }

  .page-title {
    font-size: 1rem;
  }

  .page-icon {
    width: 24px;
    height: 24px;
  }

  .table-compact tbody td {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.6rem 0;
  }

  .table-compact tbody td::before {
    flex: unset;
    margin-bottom: 0.2rem;
    font-size: 0.7rem;
  }

  .table-compact tbody tr {
    margin-bottom: 1rem;
    padding: 0.6rem;
  }

  .btn-xs {
    padding: 0.3rem 0.5rem;
    font-size: 0.65rem;
    white-space: nowrap;
  }

  .action-buttons {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-input {
    max-width: 150px;
  }
}

/* Mobile collapsed menu */
@media (max-width: 991px) {
  .navbar-collapse {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.5rem;
  }

  .navbar-nav {
    flex-direction: column;
    gap: 0;
  }

  .nav-link {
    min-height: auto;
    padding: 0.75rem 1rem !important;
    border-radius: var(--radius-md);
  }

  .nav-link::after {
    display: none;
  }

  .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .nav-item:last-child .nav-link {
    margin-left: 0;
    padding-left: 1rem !important;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 0.5rem;
    padding-top: 1rem !important;
  }

  .dropdown-menu-custom {
    position: static !important;
    transform: none !important;
    box-shadow: none;
    border: none;
    background: rgba(255, 255, 255, 0.03);
    margin: 0.25rem 0 0.5rem 1rem;
    padding: 0.25rem;
  }

  .dropdown-menu-custom .dropdown-item {
    color: var(--text-light);
  }

  .dropdown-menu-custom .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-white);
  }

  .dropdown-menu-custom .dropdown-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ps-teal);
  }

  .dropdown-menu-custom .dropdown-item.text-danger {
    color: #ff6b6b;
  }
}

/* Large screens (1200px+) */
@media (min-width: 1200px) {
  .navbar-custom > .container {
    min-height: 64px;
  }

  .navbar-logo-icon {
    height: 34px;
  }
}