@font-face {
    font-family: 'AlfaLaval';
    src: url('/static/fonts/AlfaLaval-Regular.woff2') format('woff2'),
         url('/static/fonts/AlfaLaval-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'AlfaLaval';
    src: url('/static/fonts/AlfaLaval-Bold.woff2') format('woff2'),
         url('/static/fonts/AlfaLaval-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'AlfaLaval';
    src: url('/static/fonts/AlfaLaval-Italic.woff2') format('woff2'),
         url('/static/fonts/AlfaLaval-Italic.woff') format('woff');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'AlfaLaval';
    src: url('/static/fonts/AlfaLaval-BoldItalic.woff2') format('woff2'),
         url('/static/fonts/AlfaLaval-BoldItalic.woff') format('woff');
    font-weight: bold;
    font-style: italic;
}

/* Alfa Laval Brand Colors */
:root {
    --impact-blue: #0068ff;
    --heritage-blue: #11387f;
    --dark-blue: #0b1128;
    --off-white: #eeeeec;
    --light-blue: #b0d1ff;
    --positive-pink: #e1caff;
    --light-green: #a0ebc3;
    --dark-sand: #7f7e79;
    --sand: #c4c3bc;
    --white: #ffffff;
    --highlight-purple: #cd14f0;
    --highlight-green: #00b441;
    --highlight-orange: #f08200;
    --highlight-red: #f03250;
}

body {
    font-family: 'AlfaLaval', sans-serif;
    margin: 0;
    padding: 0;
    background: url('/static/images/background.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--dark-blue);
}

.app-header {
    background: var(--heritage-blue);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
}

.logo-section {
    display: flex;
    align-items: center;
}

.logo {
    max-height: 50px;
    margin-right: 15px;
}

.app-title {
    margin: 0;
    font-size: 24px;
    color: var(--white);
    font-weight: bold;
}

.main-nav {
    display: flex;
}

.nav-link {
    margin: 0 15px;
    text-decoration: none;
    color: var(--white);
    font-weight: bold;
    padding: 10px;
    border-radius: 5px;
    transition: background 0.3s;
}

.nav-link:hover, .nav-link.active {
    background: var(--impact-blue);
    color: var(--white);
}

#main-content {
    margin-top: 80px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 20px;
}

.card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn {
    background: var(--impact-blue);
    color: var(--white);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.3s;
}

.btn:hover {
    background: var(--heritage-blue);
}

.btn-secondary {
    background: var(--dark-sand);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--sand);
}

form {
    display: flex;
    flex-direction: column;
}

form label {
    margin-top: 10px;
    font-weight: bold;
    color: var(--dark-blue);
}

form input, form textarea, form select, .form-select {
    padding: 10px;
    margin-top: 5px;
    border: 1px solid var(--sand);
    border-radius: 4px;
    font-family: 'AlfaLaval', sans-serif;
}

form input:focus, form textarea:focus, form select:focus, .form-select:focus {
    outline: none;
    border-color: var(--impact-blue);
    box-shadow: 0 0 5px var(--light-blue);
}

textarea {
    resize: vertical;
    padding-left: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* Tables inside cards should be plain to avoid double styling */
.card table {
    background: transparent;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

table th, table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--sand);
}

table th {
    background: var(--off-white);
    font-weight: bold;
    color: var(--dark-blue);
}

table tbody tr:hover {
    background: var(--light-blue);
}

table select {
    padding: 8px;
    border: 1px solid var(--sand);
    border-radius: 4px;
    font-family: 'AlfaLaval', sans-serif;
    background: var(--white);
    color: var(--dark-blue);
}

table select:focus {
    outline: none;
    border-color: var(--impact-blue);
    box-shadow: 0 0 5px var(--light-blue);
}

/* Additional Styles */
h1, h2, h3 {
    color: var(--heritage-blue);
    margin-bottom: 20px;
}

p {
    line-height: 1.6;
    color: var(--dark-blue);
}

a {
    color: var(--impact-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Status colors */
.status-draft {
    color: var(--dark-sand);
}

.status-submitted {
    color: var(--highlight-orange);
}

.status-approved {
    color: var(--highlight-green);
}

.status-rejected {
    color: var(--highlight-red);
}

.status-signed {
    color: var(--impact-blue);
}

/* Status badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px;
}

/* Icon buttons */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    margin: 0 2px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

.btn-icon:active {
    background-color: rgba(0, 123, 255, 0.2);
}

.status-completed {
    background: #d4edda;
    color: #155724;
}

.status-approved {
    background: #d1ecf1;
    color: #0c5460;
}

.status-submitted {
    background: #fff3cd;
    color: #856404;
}

.status-draft {
    background: #f8f9fa;
    color: #6c757d;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1002;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal > .modal-content {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 20px;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 18px;
    min-width: auto;
}

/* Enhanced modal styles */
.modal-form {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--sand);
}

.modal-header h3 {
    margin: 0;
    color: var(--heritage-blue);
}

.modal-close {
    font-size: 28px;
    font-weight: bold;
    color: var(--dark-sand);
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.modal-close:hover {
    color: var(--dark-blue);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--off-white);
}

/* Form styles */
.form-grid {
    display: grid;
    gap: 20px;
}

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

.form-group.required label::after {
    content: " *";
    color: var(--highlight-red);
}

.form-group label {
    font-weight: bold;
    color: var(--dark-blue);
    margin-bottom: 8px;
}

.form-group input {
    padding: 12px;
    border: 2px solid var(--sand);
    border-radius: 6px;
    font-family: 'AlfaLaval', sans-serif;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--impact-blue);
    box-shadow: 0 0 0 3px var(--light-blue);
}

.form-group input:invalid:not(:placeholder-shown) {
    border-color: var(--highlight-red);
}

.error-message {
    color: var(--highlight-red);
    font-size: 14px;
    margin-top: 5px;
    min-height: 18px;
}

/* Button enhancements */
.btn:disabled {
    background: var(--dark-sand);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-text, .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#signature-modal > div {
    max-width: 500px;
}

/* Tab navigation */
.tab-navigation {
    display: flex;
    border-bottom: 2px solid var(--sand);
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: var(--text);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(0,0,0,0.05);
}

.tab-btn.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.tab-content {
    padding: 20px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        padding: 10px;
    }

    .logo-section {
        margin-bottom: 10px;
    }

    .app-title {
        font-size: 20px;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-link {
        margin: 5px 10px;
        padding: 8px;
        font-size: 14px;
    }

    #main-content {
        padding: 10px;
        margin-top: 100px;
    }

    table {
        font-size: 14px;
    }

    .card {
        padding: 15px;
    }

    form input, form textarea, form select {
        padding: 8px;
    }

    #signature-canvas {
        width: 100%;
        max-width: 400px;
        height: 200px;
        display: block;
    }
}
/* Hamburger menu */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: 10px;
}
.hamburger span {
    display: block;
    width: 26px;
    height: 3px;
    background: var(--white);
    margin: 5px 0;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.hamburger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Mobile navigation behavior */
@media (max-width: 768px) {
    .header-content {
        position: relative; /* enable absolute nav positioning */
    }
    .hamburger {
        display: block;
    }
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--heritage-blue);
        display: none; /* hidden by default on mobile */
        flex-direction: column;
        padding: 10px 16px 16px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.2);
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
        z-index: 1000;
    }
    .main-nav.open {
        display: flex; /* shown when hamburger toggled */
    }
    .nav-link {
        margin: 6px 0;
        padding: 10px 12px;
        font-size: 16px;
        border-radius: 8px;
    }
}

/* Install modal tweaks */
#install-modal .modal-content h3 {
    color: var(--heritage-blue);
}
/* Fix: ensure hamburger button has no white background across browsers */
.hamburger {
    background: transparent;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Mobile navigation override fixes (placed at end to win cascade) */
@media (max-width: 768px) {
    .header-content { position: relative; }

    /* Ensure hamburger is visible and styled nicely on iOS Safari */
    #hamburger-btn.hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
        margin-left: 10px;
        background: transparent;
        border: none;
        -webkit-appearance: none;
        appearance: none;
    }
    #hamburger-btn.hamburger span {
        display: block;
        width: 26px;
        height: 3px;
        background: var(--white);
        margin: 5px 0;
        border-radius: 2px;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    #hamburger-btn.hamburger.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    #hamburger-btn.hamburger.active span:nth-child(2) { opacity: 0; }
    #hamburger-btn.hamburger.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

    /* Hide nav by default on mobile; show only when toggled open */
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--heritage-blue);
        display: none !important; /* force override of earlier flex rule */
        flex-direction: column;
        padding: 10px 16px 16px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.2);
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
        z-index: 1002; /* above header content */
    }
    .main-nav.open {
        display: flex !important;
    }

    .nav-link {
        margin: 6px 0;
        padding: 10px 12px;
        font-size: 16px;
        border-radius: 8px;
    }
}
/* Ensure hamburger hidden on desktop and styled via SVG (fix white square/stripe) */
.hamburger {
    display: none !important; /* hidden on desktop */
    background: transparent !important;
    border: 0 !important;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
}

/* SVG-based hamburger icon styling */
.hamburger svg {
    display: block;
    width: 28px;
    height: 28px;
    pointer-events: none; /* allow clicks to the button */
}
.hamburger .line {
    stroke: var(--white);
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-box: fill-box;
    transform-origin: 12px 12px; /* center of 24x24 viewBox */
}

/* Animate to "X" when active */
.hamburger.active .top {
    transform: translateY(6px) rotate(45deg);
}
.hamburger.active .middle {
    opacity: 0;
}
.hamburger.active .bottom {
    transform: translateY(-6px) rotate(-45deg);
}

/* Mobile layout: show hamburger, hide nav until opened */
@media (max-width: 768px) {
    #hamburger-btn.hamburger {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 8px;
        margin-left: 10px;
    }

    /* Strong override: nav hidden by default on phones */
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--heritage-blue);
        display: none !important;
        flex-direction: column;
        padding: 10px 16px 16px;
        box-shadow: 0 6px 16px rgba(0,0,0,0.2);
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
        z-index: 1002;
    }
    .main-nav.open {
        display: flex !important;
    }

    .nav-link {
        margin: 6px 0;
        padding: 10px 12px;
        font-size: 16px;
        border-radius: 8px;
    }
}
/* Tab Styles */
.tab-btn {
    background: var(--off-white);
    border: 2px solid var(--sand);
    color: var(--dark-blue);
    padding: 12px 20px;
    margin-right: 5px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    border-bottom: none;
}

.tab-btn:hover {
    background: var(--light-blue);
    color: var(--dark-blue);
}

.tab-btn.active {
    background: var(--impact-blue);
    color: var(--white);
    border-color: var(--impact-blue);
}

.tab-content {
    display: none;
    padding: 20px;
    border: 2px solid var(--sand);
    border-top: none;
    border-radius: 0 8px 8px 8px;
    background: var(--off-white);
}

/* Enhanced Modal Styles */
.modal-form {
    max-width: 600px;
    width: 90vw;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--sand);
    background: transparent;
    color: var(--heritage-blue);
    border-radius: 12px 12px 0 0;
}

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

.modal-close {
    font-size: 28px;
    cursor: pointer;
    color: var(--dark-sand);
    transition: color 0.3s;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--sand);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.modal-close:hover {
    color: var(--dark-blue);
    background: rgba(255, 255, 255, 0.2);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--sand);
    background: transparent;
    border-radius: 0 0 12px 12px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.required label::after {
    content: " *";
    color: var(--highlight-red);
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--dark-blue);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--sand);
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--impact-blue);
    box-shadow: 0 0 5px var(--light-blue);
}

.error-message {
    color: var(--highlight-red);
    font-size: 14px;
    margin-top: 5px;
}

.btn:disabled {
    background: var(--dark-sand);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Form Grid */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
}

.selected-customer {
    background-color: var(--highlight-purple) !important;
    border: 2px solid var(--impact-blue) !important;
}

/* Mobile header layout: keep one row and place hamburger left of logo */
@media (max-width: 768px) {
  .header-content {
    display: flex;
    flex-direction: row !important; /* override earlier column layout */
    justify-content: space-between;
    align-items: center;
  }
  .logo-section {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .logo-link {
    display: inline-flex;
    align-items: center;
  }
  .logo {
    max-height: 44px; /* slightly smaller on mobile to reduce header height */
  }
  .app-title {
    margin: 0;
    font-size: 20px;
  }

  /* Mobile tab adjustments */
  .tab-btn {
      padding: 10px 15px;
      font-size: 14px;
      margin-right: 2px;
  }

  .tab-content {
      padding: 15px;
  }

  /* Mobile modal adjustments */
  .modal-form {
      width: 95vw;
      max-width: none;
  }

  .modal-header,
  .modal-footer {
      padding: 15px;
  }

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