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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;
}

/* Container */
.container {
  max-width: 100%;
  margin: 0 auto;
  background-color: white;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  padding: 20px 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: white;
  text-align: center;
}

.property-info {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 12px 15px;
  border-radius: 8px;
  margin-top: 10px;
  text-align: center;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.property-info p {
  margin: 4px 0;
  opacity: 0.9;
}

/* Main Content - Two Panels */
.main-content {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 180px);
  gap: 0;
}

/* Left Panel - Edit Form (30% width) */
.left-panel {
  flex: 0 0 30%;
  max-width: 30%;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.left-panel::-webkit-scrollbar {
  width: 6px;
}

.left-panel::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.left-panel::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.form-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 15px;
  border-bottom: 2px solid #3498db;
}

.form-header h2 {
  color: #2c3e50;
  font-size: 1.4rem;
  margin: 0;
}

.form-header .icon {
  margin-right: 8px;
}

.btn-clear {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-clear:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

/* Form Sections */
.form-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border: 1px solid #e8e8e8;
}

.form-section h3 {
  color: #2c3e50;
  font-size: 1.1rem;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
}

.section-icon {
  margin-right: 8px;
  font-size: 1.2rem;
}

/* Form Groups */
.form-group {
  margin-bottom: 15px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

/* Advanced Input Fields */
.advanced-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: all 0.3s;
  background: #fff;
}

.advanced-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.advanced-input:hover {
  border-color: #b0b0b0;
}

.advanced-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 60px;
  max-height: 120px;
  transition: all 0.3s;
  background: #fff;
}

.advanced-textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Form Rows */
.form-row.stacked {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.form-row.stacked .form-group {
  width: 100%;
  margin-bottom: 0;
}

.form-row {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.form-group.half {
  flex: 1;
}

/* Custom Autocomplete */
.autocomplete-items {
  position: absolute;
  border: 1px solid #d4d4d4;
  border-bottom: none;
  border-top: none;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.autocomplete-items div {
  padding: 10px;
  cursor: pointer;
  background-color: #fff;
  border-bottom: 1px solid #d4d4d4;
  font-size: 0.9rem;
}

.autocomplete-items div:hover {
  background-color: #e9e9e9;
}

.autocomplete-active {
  background-color: #3498db !important;
  color: #ffffff;
}

/* Agreement Selector */
.agreement-selector {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid #e0e0e0;
}

.selector-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.selector-field {
  flex: 1;
  min-width: 200px;
}

.selector-field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

.selector-field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
  transition: all 0.3s;
}

.selector-field select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

#agreementStatus {
  margin-top: 10px;
  padding: 8px;
  border-radius: 4px;
  font-size: 0.9rem;
}

#agreementStatus.status-success {
  color: #27ae60;
  background: rgba(39, 174, 96, 0.1);
}

#agreementStatus.status-error {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

#agreementStatus.status-warning {
  color: #f39c12;
  background: rgba(243, 156, 18, 0.1);
}

#agreementStatus.status-info {
  color: #3498db;
  background: rgba(52, 152, 219, 0.1);
}

/* Form Actions - Button Rows */
.form-actions {
  padding-top: 20px;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Button row - 2 columns on wide screen */
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-row button {
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.95rem;
  width: 100%;
}

.btn-delete {
  background: #e74c3c;
  color: white;
}

.btn-delete:hover {
  background: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.btn-save-server {
  background: #27ae60;
  color: white;
}

.btn-save-server:hover {
  background: #219653;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.btn-publish {
  background: #8e44ad;
  color: white;
}

.btn-publish:hover {
  background: #732d91;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(142, 68, 173, 0.3);
}

.btn-copy-url {
  background: #1abc9c;
  color: white;
}

.btn-copy-url:hover {
  background: #16a085;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(26, 188, 156, 0.3);
}

.btn-icon {
  font-size: 1.1rem;
}

/* Save Status */
.save-status {
  text-align: center;
  color: #666;
  font-size: 0.85rem;
  opacity: 0.8;
  padding: 5px;
  border-radius: 4px;
  background: #f8f9fa;
  transition: all 0.3s;
}

.status-icon {
  margin-right: 5px;
}

.status-success {
  color: #27ae60 !important;
  background: rgba(39, 174, 96, 0.1) !important;
}

.status-error {
  color: #e74c3c !important;
  background: rgba(231, 76, 60, 0.1) !important;
}

.status-warning {
  color: #f39c12 !important;
  background: rgba(243, 156, 18, 0.1) !important;
}

.status-info {
  color: #3498db !important;
  background: rgba(52, 152, 219, 0.1) !important;
}

/* Right Panel - Preview (70% width) */
.right-panel {
  flex: 1;
  background: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.preview-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  overflow: hidden;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.preview-header h2 {
  color: #2c3e50;
  font-size: 1.4rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-control {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s;
}

.btn-control:hover {
  background: #f5f5f5;
  border-color: #3498db;
}

.zoom-level {
  min-width: 50px;
  text-align: center;
  font-size: 0.9rem;
  color: #666;
}

/* Preview Content */
.preview-content {
  flex: 1;
  padding: 20px;
  background: #f9f9f9;
  overflow: auto;
  position: relative;
  transition: transform 0.3s ease;
}

/* A4 Preview Style */
.preview-content .a4-preview {
  background: white;
  padding: 40px 50px;
  margin: 0 auto;
  width: 210mm;
  min-height: 297mm;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  font-family: 'Times New Roman', Times, serif;
  line-height: 1.7;
  transform-origin: top center;
}

.preview-content .a4-preview h1 {
  text-align: center;
  text-decoration: underline;
  margin: 30px 0 20px 0;
  font-size: 28px;
  color: #000;
}

.preview-content .a4-preview h2 {
  text-align: center;
  text-decoration: underline;
  margin: 25px 0 15px 0;
  font-size: 20px;
  color: #000;
}

.preview-content .a4-preview h3 {
  text-align: center;
  font-size: 14px;
  font-weight: normal;
  margin: -5px 0 10px 0;
  color: #555;
}

.preview-content .a4-preview p {
  margin: 15px 0;
  font-size: 16px;
  text-align: justify;
}

.preview-content .a4-preview pre {
  background: #f5f5f5;
  padding: 15px;
  border-radius: 4px;
  border-left: 4px solid #3498db;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  white-space: pre-wrap;
  margin: 15px 0;
}

.preview-content .a4-preview .tenant-details {
  border-left-color: #e74c3c;
}

.preview-content .a4-preview .parties-container {
  display: flex;
  gap: 40px;
  margin-top: 20px;
}

.preview-content .a4-preview .party-box {
  flex: 1;
}

.preview-content .a4-preview ol {
  padding-left: 40px;
  margin: 20px 0;
}

.preview-content .a4-preview li {
  margin-bottom: 12px;
  font-size: 15px;
  text-align: justify;
}

.preview-content .a4-preview table {
  width: 100%;
  margin: 30px 0;
  border-collapse: collapse;
}

.preview-content .a4-preview td {
  padding: 12px;
  vertical-align: top;
  border: 1px solid #ddd;
}

/* Reserved stamp space at the top of page 1: 108.5mm, using an absolute unit
   rather than a percentage, since .a4-preview only has min-height (not
   height), and a percentage-height child of a min-height-only parent
   resolves to 0 - which is why the old height:45% div wasn't actually
   reserving any space when printed. */
.preview-content .a4-preview .stamp-space {
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-content .a4-preview .stamp-hint {
  color: #ccc;
  font-size: 14px;
  font-style: italic;
  border: 2px dashed #ddd;
  padding: 10px 20px;
  border-radius: 6px;
}

/* Print page break classes */
.page-break-before {
  page-break-before: always;
}

/* Fullscreen Mode */
.fullscreen-mode .preview-content {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background: white !important;
  padding: 20px !important;
  margin: 0 !important;
  border-radius: 0 !important;
  overflow: auto !important;
}

.fullscreen-active {
  overflow: hidden !important;
}

/* Footer */
footer {
  background: #2c3e50;
  color: white;
  padding: 25px 30px;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.contact-info {
  margin-bottom: 20px;
}

.contact-info h3 {
  color: #3498db;
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.contact-info p {
  margin: 5px 0;
  color: #ecf0f1;
  font-size: 0.95rem;
}

.seo-text {
  background: rgba(255,255,255,0.05);
  padding: 20px;
  border-radius: 6px;
  margin: 20px 0;
}

.seo-text h4 {
  color: #3498db;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.seo-text p {
  text-align: justify;
  color: #ecf0f1;
  line-height: 1.7;
  font-size: 0.95rem;
}

.copyright {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #bdc3c7;
  font-size: 0.9rem;
}

.copyright p {
  margin: 5px 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }
  
  .left-panel {
    flex: 0 0 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
  
  .right-panel {
    flex: 1;
  }
  
  .preview-content .a4-preview {
    width: 100%;
    padding: 20px;
  }
}

@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }
  
  .form-row {
    flex-direction: column;
    gap: 10px;
  }
  
  .form-group.half {
    flex: 1 0 100%;
  }
  
  .button-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .button-row button {
    padding: 14px 20px;
    font-size: 1rem;
  }
  
  .preview-header {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  
  .preview-controls {
    justify-content: center;
  }
  
  .form-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .btn-clear {
    width: 100%;
  }
  
  .selector-group {
    flex-direction: column;
  }
  
  .selector-field {
    width: 100%;
  }

  .preview-content .a4-preview .parties-container {
    flex-direction: column;
    gap: 20px;
  }
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  
  .preview-content .a4-preview,
  .preview-content .a4-preview * {
    visibility: visible;
  }
  
  .preview-content .a4-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20mm;
    margin: 0;
    box-shadow: none;
    background: white;
  }
  
  @page {
    size: A4;
    margin: 20mm;
  }

  .preview-content .a4-preview .parties-container {
    display: flex !important;
    gap: 40px !important;
    margin-top: 20px !important;
  }

  .preview-content .a4-preview .party-box {
    flex: 1 !important;
  }

  .preview-content .a4-preview h1 {
    margin: 15mm 0 10mm 0 !important;
    font-size: 22pt !important;
  }

  .preview-content .a4-preview h2 {
    font-size: 16px !important;
  }

  .preview-content .a4-preview pre {
    font-size: 12px !important;
    padding: 10px !important;
  }

  .preview-content .a4-preview .stamp-space {
    height: 108.5mm !important;
  }

  .preview-content .a4-preview .stamp-hint {
    display: none !important;
  }
}


/* ============================================================
   TENANT AADHAAR DOCUMENT UPLOAD
   ============================================================ */

/* File input container */
.form-group .file-upload-wrapper {
    position: relative;
    width: 100%;
    margin-top: 4px;
}

/* File input styling */
#tenantAadhaarDoc {
    width: 100%;
    padding: 12px 14px;
    border: 2px dashed #d0d0d0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #555;
}

#tenantAadhaarDoc:hover {
    border-color: #3498db;
    background: #f0f7ff;
}

#tenantAadhaarDoc:focus {
    outline: none;
    border-color: #3498db;
    background: #f0f7ff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

/* File input - when file is selected */
#tenantAadhaarDoc.has-file {
    border-color: #27ae60;
    background: #f0fff4;
}

/* File input - when error */
#tenantAadhaarDoc.has-error {
    border-color: #e74c3c;
    background: #fff5f5;
}

/* Small helper text */
.form-group .file-hint {
    display: block;
    color: #888;
    font-size: 11px;
    margin-top: 5px;
    font-weight: normal;
}

/* Status message for the uploaded file */
#aadhaarDocStatus {
    font-size: 13px;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

#aadhaarDocStatus.status-success {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.08);
    border-left: 3px solid #27ae60;
}

#aadhaarDocStatus.status-error {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.08);
    border-left: 3px solid #e74c3c;
}

#aadhaarDocStatus.status-info {
    color: #3498db;
    background: rgba(52, 152, 219, 0.08);
    border-left: 3px solid #3498db;
}

#aadhaarDocStatus.status-warning {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.08);
    border-left: 3px solid #f39c12;
}

/* Status icon */
#aadhaarDocStatus .status-icon {
    font-size: 16px;
}

/* File name display */
#aadhaarDocStatus .file-name {
    font-weight: 600;
    word-break: break-all;
}

/* File size display */
#aadhaarDocStatus .file-size {
    color: #888;
    font-size: 12px;
}

/* Remove file button (optional) */
.btn-remove-file {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    margin-left: auto;
    transition: color 0.2s;
}

.btn-remove-file:hover {
    color: #c0392b;
    text-decoration: underline;
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */

@media (max-width: 768px) {
    #tenantAadhaarDoc {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    #aadhaarDocStatus {
        font-size: 12px;
        padding: 4px 8px;
    }
}

@media (max-width: 480px) {
    #tenantAadhaarDoc {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    #aadhaarDocStatus {
        font-size: 11px;
        padding: 4px 6px;
        flex-wrap: wrap;
    }
}

/* ============================================================
   PRINT STYLES (hide file upload in print)
   ============================================================ */

@media print {
    #tenantAadhaarDoc,
    #aadhaarDocStatus,
    .file-hint,
    .file-upload-wrapper {
        display: none !important;
    }
}