/* ========================================
   CSS VARIABLES & RESET
   ======================================== */
:root {
  --primary: #016db7;
  --primary-dark: #015a9a;
  --primary-light: #0284c7;
  --secondary: #6d6964;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --bg: #f0f4f8;
  --card: rgba(255, 255, 255, 0.95);
  --card-glass: rgba(255, 255, 255, 0.85);
  --muted: #6d6964;
  --text-primary: #0f172a;
  --border: rgba(148, 163, 184, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */
.sidebar {
  width: 260px;
  padding: 28px 20px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  position: fixed;
  height: 100vh;
  top: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
}



.brand {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.brand-sub {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 4px;
  font-weight: 400;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.tab {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  padding: 12px 16px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.tab::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--primary-light);
  transform: scaleY(0);
  transition: transform 0.25s ease;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(4px);
}

.tab:hover::before {
  transform: scaleY(1);
}

.tab.active {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(1, 109, 183, 0.3);
  transform: translateX(4px);
}

.tab.active::before {
  transform: scaleY(1);
}

.sidebar-note {
  margin-top: auto;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 14px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.swatch.primary {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
}

.swatch.secondary {
  background: var(--secondary);
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
.main {
  flex: 1;
  padding: 32px;
  width: calc(100% - 260px);
  max-width: none;
  margin: 0;
  margin-left: 260px;
  background: transparent;
}

.page-head h1 {
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.muted {
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 15px;
}

/* ========================================
   FORM CARDS & TABS
   ======================================== */
.form-tab {
  background: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  transition: all 0.3s ease;
}

.form-tab:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.form-tab.hidden {
  display: none;
}

.form-tab h2 {
  margin-bottom: 20px;
  color: var(--primary);
  font-size: 24px;
}

.form-tab h3 {
  margin: 24px 0 16px 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-weight: 500;
  letter-spacing: 0.3px;
}

input, select {
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  font-size: 14px;
  margin-top: 8px;
  background: #fff;
  transition: all 0.25s ease;
  font-family: inherit;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(1, 109, 183, 0.1);
  transform: translateY(-1px);
}

input:hover, select:hover {
  border-color: var(--primary-light);
}

/* Input hints */
.input-hint {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
  font-weight: 400;
  line-height: 1.3;
  opacity: 0.85;
}

.hidden-inline {
  display: none;
}

/* Input validation states */
input.error, select.error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

input.error:focus, select.error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

input.success, select.success {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  margin-top: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(1, 109, 183, 0.3);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(1, 109, 183, 0.4);
}

.btn:hover::before {
  left: 100%;
}

.btn:active {
  transform: translateY(0);
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
}

.btn.danger {
  background: linear-gradient(135deg, #f87171 0%, var(--danger) 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn.danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Button loading state */
.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
  cursor: not-allowed;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ========================================
   FEEDBACK MESSAGES
   ======================================== */
.feedback-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
  line-height: 1.4;
}

.feedback-success {
  background: var(--success);
  color: white;
}

.feedback-error {
  background: var(--danger);
  color: white;
}

.feedback-warning {
  background: var(--warning);
  color: white;
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* ========================================
   OUTPUT CARD & TABLE
   ======================================== */
.card-output {
  background: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.8);
  transition: all 0.3s ease;
}

.card-output:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.output-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  margin: 0;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 52;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0);
  transition: box-shadow 0.3s ease;
}

.output-head.scrolled {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.output-head h2 {
  margin: 0;
  color: var(--primary);
  font-size: 24px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0;
}

table {
  width: 100%;
  min-width: 600px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

th, td {
  padding: 14px 12px;
  text-align: center;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}

th:first-child {
  border-top-left-radius: 12px;
}

th:last-child {
  border-top-right-radius: 12px;
}

td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  background: #fff;
}

tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: rgba(1, 109, 183, 0.05) !important;
  transform: scale(1.002);
}

tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.5);
}

.totals {
  display: flex;
  gap: 32px;
  justify-content: flex-end;
  margin: 20px 24px;
  font-size: 15px;
  font-weight: 500;
  padding: 16px;
  background: rgba(241, 245, 249, 0.6);
  border-radius: 10px;
  flex-wrap: wrap;
}

.totals strong {
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 780px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 16px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: static;
    height: auto;
    overflow-y: visible;
  }

  .brand {
    font-size: 18px;
    flex: 0 0 auto;
  }

  .brand-sub {
    display: none;
  }

  .tabs {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 0;
    flex: 1;
    justify-content: center;
    gap: 8px;
  }

  .tab {
    padding: 10px 16px;
    font-size: 13px;
  }

  .tab:hover {
    transform: translateX(0);
  }

  .tab.active {
    transform: translateX(0);
  }

  .sidebar-note {
    display: none;
  }
  
  .main {
    padding: 20px;
    margin-left: 0;
    width: 100%;
  }
  
  .page-head h1 {
    font-size: 24px;
  }

  .muted {
    font-size: 14px;
    margin-bottom: 16px;
  }
  
  .row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .form-tab, .card-output {
    padding: 16px;
    border-radius: 12px;
  }

  .form-tab h2 {
    font-size: 20px;
  }

  .form-tab h3 {
    font-size: 16px;
  }

  .table-wrapper {
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 16px;
  }
  
  table {
    min-width: 500px;
    font-size: 12px;
  }
  
  th, td {
    padding: 10px 8px;
    font-size: 11px;
  }

  .totals {
    gap: 16px;
    font-size: 13px;
    padding: 12px;
  }

  .btn {
    width: 100%;
    padding: 12px;
  }

  .output-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1;
  }

  .feedback-message {
    right: 10px;
    left: 10px;
    max-width: none;
    font-size: 13px;
  }

  .input-hint {
    font-size: 10px;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .sidebar,
  .actions,
  .btn {
    display: none;
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .card-output {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  table {
    page-break-inside: avoid;
  }
}


/* ========================================
   DIAMETER-WISE SUMMARY TABLE
   ======================================== */
.dia-summary-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--border);
}

.dia-summary-title {
  text-align: center;
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: underline;
}

.dia-summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.dia-summary-table th,
.dia-summary-table td {
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border);
  font-size: 13px;
}

.dia-summary-table thead th {
  background: var(--primary);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dia-summary-table tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.5);
}

.dia-summary-table tbody tr:hover {
  background: rgba(1, 109, 183, 0.05);
}

.dia-summary-table tfoot tr {
  background: rgba(241, 245, 249, 0.8);
  font-weight: bold;
}

.dia-summary-table tfoot td {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 780px) {
  .dia-summary-table {
    font-size: 11px;
  }
  
  .dia-summary-table th,
  .dia-summary-table td {
    padding: 8px 6px;
  }
}


/* ========================================
   SUB-TABS (NESTED TABS)
   ======================================== */
.sub-tabs-container {
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.sub-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sub-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.25s ease;
  border-bottom: 3px solid transparent;
  position: relative;
}

.sub-tab:hover {
  color: var(--primary);
  background: rgba(1, 109, 183, 0.05);
}

.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.sub-tab-content {
  padding-top: 20px;
  display: none;
  animation: fadeIn 0.3s ease;
}

.sub-tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive sub-tabs */
@media (max-width: 780px) {
  .sub-tabs {
    gap: 2px;
  }
  
  .sub-tab {
    padding: 8px 12px;
    font-size: 12px;
    flex: 1;
    text-align: center;
  }
}

/* ========================================
   Out-put table inside in the Card-output
   ======================================== */

.card-output {
    overflow-x: auto;
}

.card-output table {
    width: 100%;
    table-layout: auto;
}
