/**
 * AZ Computer Services - Invoice Application Styles
 * Matching the provided invoice design
 */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Container - Two Column Layout */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100vh;
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
}

/* Form Section - Left Side */
.form-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    max-height: calc(100vh - 40px);
}

.form-section h1 {
    color: #4A90E2;
    margin-bottom: 25px;
    font-size: 28px;
    border-bottom: 3px solid #4A90E2;
    padding-bottom: 10px;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.form-group .required {
    color: #e74c3c;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.form-group input.error,
.form-group select.error {
    border-color: #e74c3c;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* Form Row - Multiple fields in one row */
.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

/* Service Rows */
.service-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.service-row select,
.service-row input {
    padding: 8px;
}

.service-row .remove-service {
    padding: 8px 15px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.service-row .remove-service:hover {
    background-color: #c0392b;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 30px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary {
    background-color: #4A90E2;
    color: white;
}

.btn-primary:hover {
    background-color: #357ABD;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

#sign-button {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    margin-top: 20px;
}

#add-service {
    width: 100%;
}

/* Preview Section - Right Side */
.preview-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    max-height: calc(100vh - 40px);
}

.invoice-preview {
    background: white;
    max-width: 900px;
    padding: 30px;
    position: relative;
    margin: 0 auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* Invoice Header */
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.logo-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.company-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
    display: block;
}

.company-name {
    color: #4A90E2;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 2px;
    margin-top: 8px;
}

.invoice-title-section {
    text-align: right;
}

.invoice-title {
    color: #4A90E2;
    font-size: 52px;
    font-weight: bold;
    margin-bottom: 5px;
}

.website {
    color: #000;
    font-size: 11px;
}

.header-line {
    border: none;
    border-top: 3px solid #4A90E2;
    margin: 10px 0 15px 0;
}

/* Customer Info */
.customer-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 13px;
}

.info-left,
.info-right {
    flex: 1;
}

.info-right {
    text-align: right;
}

.customer-name-display {
    font-weight: bold;
    font-size: 16px;
    margin: 8px 0;
}

.phone-display,
.email-display,
.address-display {
    margin: 5px 0;
}

/* Computer Info */
.computer-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 13px;
}

.computer-model,
.computer-password {
    display: flex;
    flex-direction: column;
}

.computer-label {
    background-color: #4A90E2;
    color: white;
    padding: 10px;
    font-weight: bold;
    border-radius: 4px 4px 0 0;
}

.computer-value {
    border: 1px solid #ddd;
    border-top: none;
    padding: 10px;
    min-height: 35px;
    background-color: white;
    border-radius: 0 0 4px 4px;
}

/* Services Table */
.services-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 13px;
}

.services-table thead {
    background-color: #4A90E2;
    color: white;
}

.services-table th,
.services-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

.services-table th:first-child,
.services-table td:first-child {
    width: 60px;
    text-align: center;
}

.services-table th:last-child,
.services-table td:last-child {
    width: 120px;
    text-align: right;
}

.services-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Payment Info */
.payment-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 20px;
    font-size: 11px;
}

.payment-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-box {
    display: inline-flex;
    margin-bottom: 5px;
    width: fit-content;
}

.info-label {
    background-color: #4A90E2;
    color: white;
    padding: 6px 10px;
    font-weight: bold;
    white-space: nowrap;
}

.info-value {
    background-color: #B3D9FF;
    padding: 6px 10px;
    white-space: nowrap;
}

.payment-right {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
}

.total-box {
    display: inline-flex;
    margin-bottom: 5px;
}

.total-label {
    background-color: #4A90E2;
    color: white;
    padding: 6px 10px;
    font-weight: bold;
    white-space: nowrap;
}

.total-value {
    background-color: #B3D9FF;
    padding: 6px 10px;
    min-width: 100px;
    text-align: right;
    font-weight: bold;
    font-size: 14px;
}

/* Signature Section */
.signature-section {
    margin-bottom: 40px;
    margin-top: 30px;
    text-align: right;
}

.signature-display {
    margin-bottom: 10px;
    display: flex;
    justify-content: flex-end;
}

.signature-display img {
    max-width: 250px;
    max-height: 100px;
    border: none;
    background: transparent;
}

.signature-line {
    border-top: 2px solid #000;
    width: 350px;
    margin-left: auto;
    margin-bottom: 8px;
}

.signature-info {
    font-size: 13px;
    display: flex;
    justify-content: flex-end;
    gap: 30px;
}

.signature-name {
    font-weight: bold;
}

/* Invoice Footer */
.invoice-footer {
    margin-top: 30px;
    padding: 15px 0;
    border-top: 3px solid #4A90E2;
}

.invoice-footer h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: #333;
}

.footer-text {
    font-size: 11px;
    line-height: 1.6;
    text-align: justify;
    margin-bottom: 20px;
    color: #555;
}

.contact-info {
    display: flex;
    justify-content: space-around;
    padding: 15px 0;
    border-top: 2px solid #4A90E2;
    font-size: 12px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.contact-item .icon {
    font-size: 16px;
}

/* Signature Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    max-width: 600px;
    width: 90%;
}

.modal-content h2 {
    color: #4A90E2;
    margin-bottom: 20px;
    font-size: 24px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    color: #999;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

#signature-pad {
    border: 2px solid #4A90E2;
    border-radius: 4px;
    cursor: crosshair;
    display: block;
    width: 100%;
    height: 200px;
    touch-action: none;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 15px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    font-size: 16px;
}

/* Responsive Design */

/* Tablets and smaller desktops (1200px and below) */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        height: auto;
        padding: 15px;
    }
    
    .form-section,
    .preview-section {
        max-height: none;
    }
    
    .preview-section {
        order: 2;
        margin-top: 20px;
    }
    
    .invoice-preview {
        padding: 20px;
    }
}

/* Tablets (992px and below) */
@media (max-width: 992px) {
    .form-section,
    .preview-section {
        padding: 20px;
    }
    
    .form-section h1 {
        font-size: 24px;
    }
    
    .invoice-title {
        font-size: 42px;
    }
    
    .company-logo {
        width: 60px;
        height: 60px;
    }
}

/* Mobile devices (768px and below) */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 10px;
    }
    
    .form-section,
    .preview-section {
        padding: 15px;
        border-radius: 4px;
    }
    
    .form-section h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .service-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .service-row .remove-service {
        width: 100%;
        padding: 10px;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 10px 20px;
        font-size: 14px;
        width: 100%;
    }
    
    #sign-button {
        padding: 12px;
        font-size: 16px;
    }
    
    /* Invoice Preview Adjustments */
    .invoice-preview {
        padding: 15px;
    }
    
    .invoice-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }
    
    .invoice-title-section {
        text-align: center;
        margin-top: 10px;
    }
    
    .invoice-title {
        font-size: 32px;
    }
    
    .company-logo {
        width: 50px;
        height: 50px;
    }
    
    .company-name {
        font-size: 11px;
    }
    
    .customer-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .info-right {
        text-align: left;
        margin-top: 0;
    }
    
    .computer-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .services-table {
        font-size: 11px;
    }
    
    .services-table th,
    .services-table td {
        padding: 6px;
    }
    
    .payment-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .payment-right {
        width: 100%;
        align-items: flex-start;
    }
    
    .info-box,
    .total-box {
        width: 100%;
    }
    
    .info-label,
    .info-value,
    .total-label,
    .total-value {
        font-size: 10px;
        padding: 8px;
    }
    
    .signature-section {
        margin-top: 20px;
    }
    
    .signature-line {
        width: 100%;
    }
    
    .signature-info {
        font-size: 11px;
        gap: 15px;
    }
    
    .invoice-footer {
        margin-top: 20px;
    }
    
    .footer-text {
        font-size: 10px;
    }
    
    .contact-info {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .contact-item {
        font-size: 11px;
    }
    
    /* Modal Adjustments */
    .modal-content {
        padding: 20px;
        width: 95%;
    }
    
    .modal-content h2 {
        font-size: 20px;
    }
    
    #signature-pad {
        height: 150px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions button {
        width: 100%;
    }
}

/* Small mobile devices (480px and below) */
@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .form-section,
    .preview-section {
        padding: 10px;
    }
    
    .form-section h1 {
        font-size: 18px;
    }
    
    .form-group label {
        font-size: 13px;
    }
    
    .form-group input,
    .form-group select {
        font-size: 13px;
        padding: 8px;
    }
    
    .invoice-preview {
        padding: 10px;
    }
    
    .invoice-title {
        font-size: 28px;
    }
    
    .company-name {
        font-size: 9px;
    }
    
    .services-table {
        font-size: 10px;
    }
    
    .services-table th,
    .services-table td {
        padding: 4px;
    }
    
    .services-table th:first-child,
    .services-table td:first-child {
        width: 30px;
    }
    
    .services-table th:last-child,
    .services-table td:last-child {
        width: 60px;
    }
    
    .signature-info {
        flex-direction: column;
        gap: 5px;
        font-size: 10px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        display: block;
    }
    
    .form-section {
        display: none;
    }
    
    .preview-section {
        box-shadow: none;
        padding: 0;
    }
    
    .invoice-footer {
        page-break-inside: avoid;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4A90E2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error Messages */
.message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 14px;
}

.message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Scrollbar Styling */
.form-section::-webkit-scrollbar,
.preview-section::-webkit-scrollbar {
    width: 8px;
}

.form-section::-webkit-scrollbar-track,
.preview-section::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.form-section::-webkit-scrollbar-thumb,
.preview-section::-webkit-scrollbar-thumb {
    background: #4A90E2;
    border-radius: 4px;
}

.form-section::-webkit-scrollbar-thumb:hover,
.preview-section::-webkit-scrollbar-thumb:hover {
    background: #357ABD;
}

/* Customer Autocomplete Styles */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #4A90E2;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.autocomplete-item:hover {
    background-color: #f5f9ff;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item .customer-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.autocomplete-item .customer-details {
    font-size: 12px;
    color: #666;
}

.customer-selected-message {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    border-radius: 4px;
    font-size: 13px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Make customer name input container relative for autocomplete positioning */
.form-group:has(#customer_name) {
    position: relative;
}
/* Shared detail layout and compact toolbar */
.detail-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px;
    background: #fff;
    min-height: 100vh;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 3px solid #4A90E2;
}

.detail-header h1 {
    color: #4A90E2;
    font-size: 26px;
    margin: 0;
}

/* Compact action toolbar for header buttons */
.action-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.action-toolbar .btn {
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 4px;
    box-shadow: none;
}

.btn.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1.2;
}

/* Edit page grid (replace wide .container usage) */
.edit-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.edit-form-grid .form-group {
    margin-bottom: 14px;
}

/* Service row styling reuse in edit page */
.edit-form-grid .service-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

/* Toolbar responsiveness */
@media (max-width: 768px) {
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .edit-form-grid {
        grid-template-columns: 1fr;
    }
}
/* --- Services Editor (embedded) --- */
.services-editor {
  margin-top: 28px;
  display: grid;
  gap: 16px;
}

.panel-edit,
.panel-list {
  background: #f8fbff;
  border: 2px dashed #B3D9FF;
  padding: 16px;
  border-radius: 8px;
}

.panel-title {
  color: #4A90E2;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-subtitle {
  color: #666;
  font-size: 13px;
  margin: 0 0 12px 0;
}

/* Add Service form */
.add-form {
  display: grid;
  gap: 10px;
}
.add-form .row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
}
.add-form label {
  font-weight: 600;
  color: #333;
}
.add-form input[type="text"],
.add-form input[type="number"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #d6e6fb;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
}
.add-form input[type="text"]:focus,
.add-form input[type="number"]:focus {
  outline: none;
  border-color: #4A90E2;
  box-shadow: 0 0 0 2px rgba(74,144,226,.12);
}

/* Table for existing services */
.services-table-editor {
  width: 100%;
  border-collapse: collapse;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  background: #fff;
}
.services-table-editor thead {
  background: #4A90E2;
  color: #fff;
}
.services-table-editor th,
.services-table-editor td {
  padding: 12px 10px;
  border: 1px solid #e6eef8;
  font-size: 14px;
  vertical-align: middle;
}
.services-table-editor th:first-child,
.services-table-editor td:first-child {
  width: 56px;
  text-align: center;
  font-weight: 700;
}
.services-table-editor th:last-child,
.services-table-editor td:last-child {
  width: 220px;
  text-align: right;
}
.services-table-editor td input[type="text"],
.services-table-editor td input[type="number"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d6e6fb;
  border-radius: 4px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.services-table-editor td input[type="text"]:focus,
.services-table-editor td input[type="number"]:focus {
  outline: none;
  border-color: #4A90E2;
  box-shadow: 0 0 0 2px rgba(74,144,226,.12);
}

/* Row action buttons */
.action-buttons-row {
  display: inline-flex;
  gap: 8px;
}

/* Small red button for delete */
.btn-danger {
  background-color: #e74c3c;
  color: #fff;
  border: none;
}
.btn-danger:hover {
  background-color: #c0392b;
}

/* Compact small buttons already exist as .btn.btn-sm; ensure consistent padding */
.btn.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.2;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  .add-form .row {
    grid-template-columns: 1fr;
  }
  .services-table-editor th:last-child,
  .services-table-editor td:last-child {
    width: 160px;
  }
}