/*
 * mbc.css - Medical Bill Calculator Main Styles
 * Version: 2.9.5 - Enhanced buttons with text labels
 */

:root {
    --primary-color: #00796b;
    --primary-dark: #004d40;
    --background-color: #f4f6f8;
    --container-bg: #fff;
    --input-bg: #e0f2f1;
    --table-bg: #e0f2f1;
    --text-color: #333;
    --text-color-dark: #e0e0e0;
    --border-color: #ccc;
    --footer-color: #888;
    --border-radius: 6px;
    --container-margin: 30px;
}

/* Base Styles */
body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 20px;
    overflow-x: hidden;
    max-width: 100%;
}

.container {
    max-width: 720px;
    margin: var(--container-margin) auto;
    padding: 30px;
    background: var(--container-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 0 0 20px 0;
    text-align: center;
}

/* Table Styles */
.table-with-total {
    margin-bottom: 16px;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background-color: var(--table-bg);
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

th, td {
    padding: 8px;
    text-align: center;
    vertical-align: middle;
    font-size: 0.95rem;
    border: none;
}

th {
    background-color: var(--primary-color);
    color: #fff;
    font-weight: 600;
    border: none;
}

td {
    background-color: var(--table-bg);
    color: var(--text-color);
    font-weight: 500;
    border: none;
}

tfoot td {
    background-color: var(--table-bg);
    color: var(--text-color);
    font-weight: bold;
    border: none;
}

/* Total Incurred Row */
.total-incurred-row td {
    background-color: var(--table-bg);
    color: var(--text-color);
    font-weight: 800;
    font-size: 1.1rem;
    padding: 12px;
    border: none;
}

#incurredTotal {
    color: red;
    font-size: 1.2rem;
    margin-left: 5px;
    font-weight: 800;
}

/* Input Styles */
input[type="number"] {
    -moz-appearance: textfield;
    width: 100%;
    padding: 6px 8px;
    box-sizing: border-box;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #fff;
    color: #333;
    max-width: 100%;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Button Styles with Text Labels */
.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.left-buttons {
    justify-content: flex-start;
}

.right-buttons {
    justify-content: flex-end;
}

.button-group button,
#themeToggle {
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.button-group button:hover,
#themeToggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.button-group button .btn-text {
    font-weight: 500;
}

/* Specific button styles */
#calculateBtn {
    background-color: #2196F3;
}

#calculateBtn:hover {
    background-color: #1976D2;
}

#addRowBtn {
    background-color: #4CAF50;
}

#addRowBtn:hover {
    background-color: #388E3C;
}

#delRowBtn {
    background-color: #F44336;
}

#delRowBtn:hover {
    background-color: #D32F2F;
}

#printPDFBtn {
    background-color: #9C27B0;
}

#printPDFBtn:hover {
    background-color: #7B1FA2;
}

#themeToggle {
    background-color: #FF9800;
}

#themeToggle:hover {
    background-color: #F57C00;
}

#clearTableBtn {
    background-color: #607D8B;
}

#clearTableBtn:hover {
    background-color: #455A64;
}

.danger-btn {
    color: white !important;
}

/* Copy functionality */
tfoot span:hover, #incurredTotal:hover {
    cursor: pointer;
    background-color: rgba(0, 121, 107, 0.1);
    border-radius: 3px;
    position: relative;
}

tfoot span:hover::after, #incurredTotal:hover::after {
    content: "\f0c5";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.8em;
    color: var(--primary-color);
    margin-left: 5px;
}

#incurredTotal:hover::after {
    color: #d32f2f;
}

/* Copied Feedback - Fixed Positioning */
.copied-feedback {
    position: fixed;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    z-index: 10000;
    animation: fadeOut 1s ease-in-out forwards;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-align: center;
    min-width: 120px;
    transform: translateX(-50%);
    left: 50%;
    top: 20px;
}

body.dark-mode .copied-feedback {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes fadeOut {
    0% { 
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    70% { 
        opacity: 1;
        transform: translateX(-50%) translateY(10px);
    }
    100% { 
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    font-size: 0.9rem;
    color: var(--footer-color);
}

footer a {
    color: teal;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer span {
    opacity: 0.8;
}

/* Dark Mode - Improved consistency */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .container {
    background-color: #1e1e1e;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

body.dark-mode input[type="number"] {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

body.dark-mode th {
    background-color: var(--primary-dark); /* Kept as #004d40 */
}

body.dark-mode .table-with-total,
body.dark-mode td,
body.dark-mode tfoot td,
body.dark-mode .total-incurred-row td {
    background-color: #121212;
}

body.dark-mode tfoot td {
    color: #e0e0e0;
}

body.dark-mode .total-incurred-row td {
    color: #e0e0e0;
}

body.dark-mode tfoot span:hover, 
body.dark-mode #incurredTotal:hover {
    background-color: rgba(0, 121, 107, 0.3);
}

body.dark-mode tfoot span:hover::after,
body.dark-mode #incurredTotal:hover::after {
    color: #4db6ac;
}

body.dark-mode #incurredTotal:hover::after {
    color: #ff6b6b;
}

body.dark-mode .copied-feedback {
    background: var(--primary-dark); /* Kept as #004d40 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode footer {
    color: #aaa;
}

/* Print Styles - Professional Medical Billing Appearance */
@media print {
  /* Reset everything to grayscale */
  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    color: #000 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  /* Force light mode appearance for printing */
  body, body.dark-mode {
    background: white !important;
    color: #000 !important;
    font-size: 12pt;
    line-height: 1.4;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  
  /* Container styling */
  .container, body.dark-mode .container {
    max-width: 100% !important;
    padding: 0.25in !important;
    margin: 0 auto !important;
    background: white !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border: none !important;
    width: auto !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure consistent box model for printing */
  html, body, body.dark-mode {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* Table styling - professional medical billing appearance */
  .table-with-total {
    background: white !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    margin-bottom: 16px !important;
    border: 1px solid #ddd !important;
    width: 100% !important;
    box-sizing: border-box !important;
    page-break-inside: avoid;
  }
  
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
  }
  
  th {
    background: #f0f0f0 !important;
    color: #000 !important;
    font-weight: bold !important;
    border: 1px solid #ddd !important;
    padding: 8px 4px !important;
  }
  
  td {
    background: white !important;
    color: #000 !important;
    border: 1px solid #ddd !important;
    padding: 8px 4px !important;
  }
  
  /* Show all table rows in print */
  tr {
    page-break-inside: avoid;
  }
  
  /* Summary rows styling */
  tfoot td {
    background: #f8f8f8 !important;
    color: #000 !important;
    font-weight: bold !important;
    border-top: 2px solid #000 !important;
  }
  
  .total-incurred-row td {
    background: #f0f0f0 !important;
    color: #000 !important;
    font-weight: bold !important;
    font-size: 1.1rem !important;
    padding: 10px 4px !important;
    border-top: 2px solid #000 !important;
  }
  
  #incurredTotal {
    color: #000 !important;
    font-weight: bold !important;
  }
  
  /* Input values as plain text */
  input[type="number"] {
    background: transparent !important;
    border: none !important;
    color: #000 !important;
    -webkit-appearance: none !important;
    -moz-appearance: textfield !important;
    appearance: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    text-align: center !important;
    outline: none !important;
    box-shadow: none !important;
    width: 100% !important;
    display: block !important;
  }
  
  /* Show all input values in print, even empty ones */
  input[type="number"]:not([value]) {
    display: block !important;
    color: #ccc !important;
  }
  
  /* Hide non-essential elements */
  .controls-container, 
  footer, 
  .button-group, 
  #themeToggle,
  .copied-feedback {
    display: none !important;
  }
  
  /* Show title in print */
  h1 {
    display: block !important;
    text-align: center !important;
    font-size: 18pt !important;
    margin: 0 0 16px 0 !important;
    color: #000 !important;
  }
  
  /* Remove any animations */
  * {
    animation: none !important;
    transition: none !important;
  }
  
  /* Page margins */
  @page {
    margin: 0.5in;
    size: auto;
  }
  
  /* Add website URL to print output */
  .container:after {
    content: "Medical Bill Calculator - medbillcalc.pages.dev";
    position: fixed;
    bottom: 0;
    right: 0;
    font-size: 8pt;
    color: #888 !important;
  }
  
  /* Force consistent box-sizing for all elements */
  *, *::before, *::after {
    box-sizing: border-box !important;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .container {
    padding: 15px;
    margin: 15px auto;
  }
  
  h1 {
    font-size: 1.4rem;
    margin: 0 0 15px 0;
  }
  
  /* Table responsiveness */
  .table-with-total {
    overflow-x: auto;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 100%;
    width: 100%;
  }
  
  th, td {
    padding: 8px 4px;
    font-size: 0.85rem;
    word-wrap: break-word;
  }
  
  /* Input field adaptations */
  input[type="number"] {
    padding: 8px 6px;
    font-size: 16px;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  /* Button group adjustments for mobile */
  .controls-container {
    flex-direction: column;
    gap: 15px;
  }
  
  .button-group {
    width: 100%;
    justify-content: center;
  }
  
  .left-buttons, .right-buttons {
    justify-content: center;
  }
  
  .button-group button,
  #themeToggle {
    padding: 10px 12px;
    font-size: 0.9rem;
    min-width: auto;
    flex: 1;
    min-width: 44px;
    white-space: nowrap;
  }
  
  /* Hide button text on mobile */
  .button-group button .btn-text {
    display: none;
  }
  
  /* Specific button adjustments */
  .button-group button i {
    font-size: 0.9rem;
  }
  
  /* Summary row adjustments */
  .total-incurred-row td {
    font-size: 0.95rem;
    padding: 10px 5px;
  }
  
  #incurredTotal {
    font-size: 1rem;
  }
  
  /* Ensure table cells don't overflow */
  td {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Footer adjustments for mobile */
  footer {
    margin-top: 20px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px;
  }
  
  h1 {
    font-size: 1.2rem;
  }
  
  th, td {
    padding: 6px 3px;
    font-size: 0.8rem;
  }
  
  input[type="number"] {
    padding: 6px 4px;
    font-size: 14px;
  }
  
  .button-group {
    gap: 4px;
  }
  
  .button-group button,
  #themeToggle {
    padding: 8px 6px;
    font-size: 0.8rem;
    min-width: 40px;
  }
  
  .button-group button i {
    font-size: 0.8rem;
  }
  
  .total-incurred-row td {
    font-size: 0.9rem;
    padding: 8px 4px;
  }
  
  #incurredTotal {
    font-size: 0.95rem;
  }
}

/* Special handling for very small screens */
@media (max-width: 360px) {
  .button-group {
    gap: 3px;
  }
  
  .button-group button,
  #themeToggle {
    padding: 6px 4px;
    font-size: 0.75rem;
    min-width: 36px;
  }
  
  .button-group button i {
    font-size: 0.75rem;
  }
}

/* Fix for iOS input zoom */
@media (max-width: 768px) {
  input[type="number"] {
    font-size: 16px !important;
  }
}

/* Better touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
  .button-group button:active,
  #themeToggle:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
  
  .button-group button,
  #themeToggle {
    min-height: 44px;
  }
  
  input[type="number"] {
    min-height: 44px;
  }
}
