/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Override Materialize Container */
.container {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ============================================
   NAVIGATION - Fluid responsive design
   ============================================ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  background: linear-gradient(135deg, #091c3a 0%, #1a3a5c 100%);
}

.nav-wrapper {
  padding: clamp(8px, 1.5vw, 14px) clamp(12px, 3vw, 30px);
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: clamp(10px, 2vw, 20px);
  height: auto !important;
  min-height: auto !important;
  line-height: normal !important;
  background: transparent;
}

/* Override Materialize nav element styles */
nav,
nav .nav-wrapper,
nav .nav-wrapper i,
nav a.sidenav-trigger,
nav a.sidenav-trigger i {
  height: auto !important;
  line-height: normal !important;
}

/* Brand logo - fluid sizing */
.brand-logo {
  display: flex !important;
  align-items: center;
  gap: clamp(8px, 1.5vw, 12px);
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0;
  /* Always keep on the left */
  margin-right: auto;
  /* Override Materialize positioning */
  position: relative !important;
  left: auto !important;
  transform: none !important;
}

/* Override Materialize nav .brand-logo styles */
nav .brand-logo {
  position: relative !important;
  left: auto !important;
  transform: none !important;
  display: flex !important;
}

.brand-logo img {
  height: clamp(32px, 5vw, 50px);
  width: auto;
  filter: brightness(0) invert(1);
  transition: transform 0.3s ease;
}

.brand-logo:hover img {
  transform: scale(1.05);
}

.brand-text {
  font-size: clamp(0.9rem, 1.8vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.5px;
  color: white;
  white-space: nowrap;
}

/* Navigation items - fluid layout */
.nav-items {
  display: flex !important;
  align-items: center;
  gap: clamp(8px, 1.5vw, 16px);
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1;
}

.nav-items li {
  display: flex !important;
  align-items: center;
  float: none !important;
}

/* User greeting - fluid text */
.user-greeting-container {
  display: flex !important;
  align-items: center;
  white-space: nowrap;
}

.user-greeting-container .material-icons {
  font-size: clamp(20px, 3vw, 28px);
}

#user-greeting {
  font-size: clamp(0.75rem, 1.2vw, 0.95rem);
  font-weight: 500;
}

/* Logout button - fluid sizing */
.logout-btn {
  margin: 0 !important;
  border-radius: 25px;
  padding: clamp(4px, 0.8vw, 8px) clamp(10px, 1.8vw, 20px) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  font-size: clamp(0.75rem, 1.1vw, 0.95rem);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* Menu trigger - shown only on small screens */
li.menu-trigger {
  display: none !important;
}

li.menu-trigger a {
  padding: clamp(6px, 1vw, 10px) !important;
}

li.menu-trigger .material-icons {
  font-size: clamp(22px, 3.5vw, 28px);
}

@media screen and (max-width: 992px) {
  li.menu-trigger {
    display: flex !important;
  }

  /* Override Materialize centering of brand-logo */
  nav .brand-logo {
    left: auto !important;
    transform: none !important;
    position: relative !important;
  }
}

/* Mobile layout - brand-logo on first line, nav-items on second, all centered */
@media screen and (max-width: 480px) {
  .nav-wrapper {
    justify-content: center;
    gap: clamp(8px, 1.5vw, 12px);
  }

  .brand-logo {
    flex-basis: 100%;
    margin-right: 0;
    justify-content: center;
  }

  .nav-items {
    flex-basis: 100%;
    justify-content: center;
    gap: clamp(6px, 1vw, 10px);
  }
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

.main-layout {
  display: flex;
  /* Fluid margin-top that adapts to navbar height */
  margin-top: clamp(70px, 12vw, 100px);
  min-height: calc(100vh - clamp(70px, 12vw, 100px));
  width: 100%;
  position: relative;
}

@media screen and (max-width: 992px) {
  .main-layout {
    flex-direction: column;
  }
}

@media screen and (max-width: 480px) {
  .main-layout {
    margin-top: clamp(120px, 25vw, 160px);
    min-height: calc(100vh - clamp(120px, 25vw, 160px));
  }
}

/* Sidebar styles are in sidebar-styles.css */
#nav-container {
  border: none;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 30px;
  background: transparent;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  margin-left: 280px;
}

@media screen and (max-width: 992px) {
  .main-content {
    margin-left: 0;
    padding: 20px;
  }
}

@media screen and (max-width: 768px) {
  .main-content {
    padding: 15px;
  }
}

@media screen and (max-width: 480px) {
  .main-content {
    padding: 12px;
  }
}

.content-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* ============================================
   CARD PANELS
   ============================================ */

.card-panel {
  border-radius: 16px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
  background: white;
  padding: clamp(20px, 4vw, 35px) !important;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.8);
  animation: slideIn 0.5s ease;
  width: 100%;
  max-width: 100%;
}

.card-panel h4,
.card-panel h2 {
  color: #091c3a;
  font-weight: 700;
  margin-bottom: clamp(10px, 2vw, 15px);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  line-height: 1.3;
}

.card-panel p {
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  line-height: 1.6;
  color: #64748b;
}

@media screen and (max-width: 768px) {
  .card-panel {
    padding: 25px !important;
    border-radius: 12px !important;
  }

  .card-panel h4,
  .card-panel h2 {
    font-size: clamp(1.2rem, 4vw, 1.6rem);
  }
}

@media screen and (max-width: 480px) {
  .card-panel {
    padding: 15px !important;
    border-radius: 12px !important;
  }

  .card-panel h4,
  .card-panel h2 {
    font-size: clamp(1.1rem, 5vw, 1.4rem);
    margin-bottom: 10px;
  }

  .card-panel p {
    font-size: 0.9rem;
  }
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress {
  background-color: #e0e7ff !important;
  border-radius: 10px;
  overflow: hidden;
  height: 6px;
}

.progress .indeterminate {
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* ============================================
   APP PILLS
   ============================================ */

.app-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 600;
  color: #334155;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: normal;
  word-break: break-word;
  position: relative;
  overflow: hidden;
  user-select: none;
  min-height: 44px;
  flex-direction: column;
  align-items: flex-start;
}

.app-item-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.app-item .app-name {
  font-weight: 600;
  line-height: 1.3;
}

.app-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.app-item:hover::before {
  opacity: 1;
}

.app-item:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: #667eea;
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-3px) scale(1.05);
}

.app-item:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.app-item.dragging {
  opacity: 0.6;
  border-style: dashed;
  background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
  transform: rotate(2deg) scale(0.95);
}

@media screen and (max-width: 768px) {
  .app-item {
    padding: 8px 14px;
    font-size: 0.9em;
  }
}

@media screen and (max-width: 600px) {
  .app-item {
    padding: 7px 12px;
    font-size: 0.85em;
  }
}

@media screen and (max-width: 480px) {
  .app-item {
    padding: 6px 10px;
    font-size: 0.8em;
  }
}

/* ============================================
   BUTTONS
   ============================================ */

.edit-btn {
  background: linear-gradient(135deg, #4db6ac 0%, #26a69a 100%) !important;
  color: white !important;
  padding: 11px 22px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 16px rgba(77, 182, 172, 0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.edit-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

.edit-btn:hover::before {
  width: 300px;
  height: 300px;
}

.edit-btn:hover {
  background: linear-gradient(135deg, #26a69a 0%, #00897b 100%) !important;
  box-shadow: 0 8px 24px rgba(77, 182, 172, 0.5);
  transform: translateY(-2px);
}

.save-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 36px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-size: 1.05em;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.save-btn:hover {
  background: linear-gradient(135deg, #6b82eb 0%, #7e56ab 100%);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.6);
  transform: translateY(-3px);
}

.save-btn.cancel-btn {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  box-shadow: 0 8px 24px rgba(100, 116, 139, 0.4);
}
.save-btn.cancel-btn:hover {
  background: linear-gradient(135deg, #6e7f91 0%, #516274 100%);
  box-shadow: 0 12px 32px rgba(100, 116, 139, 0.6);
  transform: translateY(-3px);
}

.save-btn.danger-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
}
.save-btn.danger-btn:hover {
  background: linear-gradient(135deg, #f05252 0%, #e53535 100%);
  box-shadow: 0 12px 32px rgba(239, 68, 68, 0.6);
  transform: translateY(-3px);
}

.btn.red {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
  border-radius: 30px;
  padding: 16px 36px;
  font-weight: 700;
  letter-spacing: 1.2px;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
  transition: all 0.3s ease;
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.red:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  box-shadow: 0 12px 32px rgba(239, 68, 68, 0.6);
  transform: translateY(-3px);
}

.button-group {
  display: flex;
  gap: 15px;
  margin-top: 30px;
  align-items: center;
}

.button-group .save-btn,
.button-group .btn.red {
  margin: 0;
}

@media screen and (max-width: 768px) {
  .button-group {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .button-group .save-btn,
  .button-group .btn.red {
    width: 100%;
    padding: 14px 28px;
    font-size: 0.95em;
  }
}

@media screen and (max-width: 600px) {
  .edit-btn {
    padding: 9px 16px;
    font-size: 0.85em;
  }

  .save-btn,
  .btn.red {
    padding: 12px 24px;
    font-size: 0.9em;
  }
}

@media screen and (max-width: 480px) {
  .edit-btn {
    padding: 8px 14px;
    font-size: 0.8em;
  }

  .save-btn,
  .btn.red {
    padding: 11px 20px;
    font-size: 0.85em;
  }
}

/* ============================================
   TABLES
   ============================================ */

table {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
  border: none;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

table th {
  background: linear-gradient(135deg, #091c3a 0%, #1a3a5c 100%) !important;
  color: #fff !important;
  padding: 18px !important;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-size: 0.85em;
}

table td {
  padding: 16px !important;
  color: #334155;
  font-weight: 500;
}

table tr {
  transition: all 0.2s ease;
}

table tr:nth-child(even) {
  background-color: #f8f9fa;
}

table tr:hover {
  background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%) !important;
  transform: scale(1.005);
}

/* Responsive Table */
@media screen and (max-width: 992px) {
  table.responsive-table {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
  }

  table.responsive-table thead {
    display: none;
  }

  table.responsive-table tbody {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0;
  }

  table.responsive-table tbody tr {
    display: block;
    width: 100%;
    margin: 0 0 16px 0;
    padding: 8px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  table.responsive-table tbody td {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 12px 16px !important;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95rem;
  }

  table.responsive-table tbody td:before {
    content: attr(data-label);
    font-weight: 600;
    color: #091c3a;
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.7;
  }

  table.responsive-table tbody td:first-child {
    border-radius: 8px 8px 0 0;
  }

  table.responsive-table tbody td:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
  }
}

@media screen and (max-width: 768px) {
  table th,
  table td {
    padding: 12px 8px !important;
    font-size: 0.85em;
  }
}

@media screen and (max-width: 600px) {
  table th,
  table td {
    padding: 10px 6px !important;
    font-size: 0.8em;
  }
}

@media screen and (max-width: 480px) {
  table {
    font-size: 0.85em;
  }

  table th,
  table td {
    padding: 8px 4px !important;
    font-size: 0.75em;
  }

  table.responsive-table tbody td {
    padding: 8px 12px !important;
  }

  table.responsive-table tbody td:before {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }

  table.responsive-table tbody tr {
    margin: 12px 0;
  }
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

select {
  display: block !important;
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0 !important;
  border-radius: 12px;
  background-color: #ffffff !important;
  color: #1a202c !important;
  font-size: 0.95em;
  font-weight: 600;
  transition: all 0.3s ease;
  cursor: pointer;
  height: auto !important;
  line-height: 1.5;
}

select option {
  color: #1a202c;
  background-color: #ffffff;
  font-weight: 500;
  padding: 8px;
}

/* Hide Materialize dropdown completely */
.select-dropdown,
.select-wrapper input.select-dropdown {
  display: none !important;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  display: none !important;
}

select:focus {
  outline: none !important;
  border-color: #667eea !important;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15) !important;
}

select:hover {
  border-color: #c7d2fe !important;
  background-color: #f8f9fa !important;
}

/* ============================================
   ICONS
   ============================================ */

.material-icons {
  vertical-align: middle;
}

.credential-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
}

.credential-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.3);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .app-header,
  .sidenav,
  .sidenav-trigger,
  .apps-editor-overlay {
    display: none !important;
  }

  .main-layout {
    margin-top: 0;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    width: 100%;
    padding: 0;
    margin-left: 0;
  }

  .card-panel {
    box-shadow: none !important;
    border: 1px solid #e5e7eb;
  }
}

/* ============================================
   LANDSCAPE ORIENTATION FIX
   ============================================ */

@media screen and (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    position: relative;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
}
