@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800&family=Montserrat:wght@400;500;600;700&family=Noto+Serif+Devanagari:wght@500;600;700&display=swap');

/* ===== RESET & BASE ===== */
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;background:#e8f5e9;min-height:100vh}
.required{color:#d32f2f}
.optional{color:#888;font-size:0.85em;font-weight:400}

/* ===== APP CONTAINER ===== */
.app-container{max-width:1300px;margin:0 auto;padding:20px}

/* ===== FORM SECTION ===== */
.form-section{max-width:560px;margin:0 auto}
.form-card{background:#fff;border-radius:16px;padding:32px;box-shadow:0 4px 24px rgba(0,0,0,0.08);border-top:5px solid #2e7d32}
.form-header{display:flex;align-items:center;justify-content:center;gap:16px;margin-bottom:28px}
.form-header h2{color:#1b5e20;font-size:1.3em}
.form-logo{height:50px;width:auto}

.form-group{margin-bottom:20px}
.form-group label{display:block;font-weight:600;color:#333;margin-bottom:6px;font-size:0.95em}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"]{width:100%;padding:12px 14px;border:2px solid #c8e6c9;border-radius:10px;font-size:1em;transition:border .2s;outline:none}
.form-group input:focus{border-color:#2e7d32}
.form-group select{width:100%;padding:12px 14px;border:2px solid #c8e6c9;border-radius:10px;font-size:1em;transition:border .2s,opacity .2s;outline:none;background:#fff;-webkit-appearance:none;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232e7d32' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;padding-right:38px;cursor:pointer;color:#333}
.form-group select:focus{border-color:#2e7d32}
.form-group select:disabled{background-color:#f5f5f5;color:#999;cursor:not-allowed;opacity:0.7;border-color:#e0e0e0}

/* ===== PHOTO UPLOAD ===== */
.photo-upload-area{border:2px dashed #a5d6a7;border-radius:12px;padding:24px;text-align:center;cursor:pointer;transition:all .2s;background:#f1f8e9;min-height:100px;display:flex;align-items:center;justify-content:center}
.photo-upload-area:hover{border-color:#2e7d32;background:#e8f5e9}
.upload-placeholder{display:flex;flex-direction:column;align-items:center;gap:8px;color:#666}
.upload-icon{font-size:2em}
.photo-preview-img{max-width:100%;max-height:180px;border-radius:10px;object-fit:cover}

/* ===== BUTTONS ===== */
.btn-generate{width:100%;padding:14px;background:#2e7d32;color:#fff;border:none;border-radius:10px;font-size:1.1em;font-weight:600;cursor:pointer;transition:background .2s;transform:translateY(-1px)}
.btn-generate:hover{background:#1b5e20;transform:translateY(-1px)}
.btn-generate:active{transform:translateY(0)}
.btn-generate:disabled{background:#a5d6a7;cursor:not-allowed}

/* ===== CERTIFICATE SECTION ===== */
.cert-section{margin-top:30px;display:flex;flex-direction:column;align-items:center}
.cert-actions{display:flex;gap:14px;margin-top:20px;flex-wrap:wrap;justify-content:center}
.btn-print,.btn-new,.btn-pdf,.btn-png{padding:12px 28px;border:none;border-radius:10px;font-size:1em;font-weight:600;cursor:pointer;transition:all .2s}
.btn-print{background:#2e7d32;color:#fff}
.btn-print:hover{background:#1b5e20}
.btn-pdf{background:linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);color:#fff;box-shadow:0 4px 12px rgba(211,47,47,0.2)}
.btn-pdf:hover{background:linear-gradient(135deg, #b71c1c 0%, #7f0000 100%);box-shadow:0 6px 16px rgba(211,47,47,0.35);transform:translateY(-1px)}
.btn-png{background:linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);color:#fff;box-shadow:0 4px 12px rgba(25,118,210,0.2)}
.btn-png:hover{background:linear-gradient(135deg, #0d47a1 0%, #002171 100%);box-shadow:0 6px 16px rgba(25,118,210,0.35);transform:translateY(-1px)}
.btn-new{background:#fff;color:#2e7d32;border:2px solid #2e7d32}
.btn-new:hover{background:#e8f5e9;transform:translateY(-1px)}

/* ===== CERTIFICATE STYLING ===== */
.certificate{width:1000px;max-width:100%;background: linear-gradient(135deg, rgba(254, 255, 254, 0.96) 0%, rgba(245, 252, 246, 0.96) 100%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M10 0 Q 20 10, 20 20 Q 25 35, 10 20 Z' fill='%232e7d32' fill-opacity='0.02'/%3E%3Cpath d='M50 40 Q 60 50, 60 60 Q 65 75, 50 60 Z' fill='%234caf50' fill-opacity='0.02'/%3E%3C/svg%3E");padding:45px 55px;border:10px double #1b5e20;box-shadow: 0 16px 48px rgba(27, 94, 32, 0.15);position:relative;margin:0 auto;box-sizing: border-box}
.certificate::before {content:'';position:absolute;top:6px;bottom:6px;left:6px;right:6px;border:2px solid #c8e6c9;pointer-events:none}
.certificate::after {content:'';position:absolute;top:12px;bottom:12px;left:12px;right:12px;border:1px solid rgba(212, 175, 55, 0.4);pointer-events:none}

.cert-top-ornament{height:4px;background:linear-gradient(90deg, transparent, #1b5e20, #d4af37, #1b5e20, transparent);margin-bottom:20px;border-radius:2px}
.cert-bottom-ornament{height:4px;background:linear-gradient(90deg, transparent, #1b5e20, #d4af37, #1b5e20, transparent);margin-top:24px;border-radius:2px}

.cert-logos{display:flex;align-items:center;justify-content:space-between;width:calc(100% + 40px);margin-left:-20px;margin-right:-20px;margin-bottom:20px;position:relative}
.cert-logo{height:110px;width:auto;filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06))}
.cert-logo-center{height:125px}

.cert-header{text-align:center;margin-bottom:24px}
.cert-header h1{font-family:'Noto Serif Devanagari', serif;font-size:2.4em;font-weight:700;color:#1b5e20;margin-bottom:6px;letter-spacing:1px;text-shadow: 1px 1px 2px rgba(0,0,0,0.05)}
.cert-header h2{font-family:'Cinzel', serif;font-size:1.35em;color:#b28704;font-weight:700;margin-bottom:8px;letter-spacing:2px}
.cert-subtitle{font-family:'Noto Serif Devanagari', serif;font-size:1.1em;color:#2e7d32;font-weight:600;letter-spacing:0.5px}

.cert-body{text-align:center;font-family:'Noto Serif Devanagari', serif;padding:0 15px}
.cert-text{font-size:1.25em;line-height:1.9;color:#2c3e50;margin-bottom:20px;text-align:justify;text-indent:30px;max-width:850px;margin-left:auto;margin-right:auto}
.cert-text strong{color:#1b5e20;font-size:1.25em;font-weight:700;border-bottom:2px solid #d4af37;padding:0 6px;margin:0 4px}

.cert-details{margin:20px 0;display:flex;flex-direction:column;align-items:center;gap:8px}
.cert-detail-row{font-size:1.1em;color:#34495e}
.cert-label{font-weight:600;color:#1b5e20}
.cert-value{color:#2c3e50;font-weight:600}

.cert-photo-wrapper{display:flex;justify-content:center;align-items:center;margin:18px auto;width:100%}
.cert-photo{width:360px;height:360px;border-radius:50%;border:4px double #d4af37;object-fit:cover;box-shadow:0 4px 15px rgba(0,0,0,0.12);display:block}

.cert-footer{display:flex;justify-content:space-between;align-items:center;margin-top:18px;padding-top:14px;border-top:1px dashed #a5d6a7;flex-wrap:wrap;gap:10px}
.cert-footer-item{font-size:0.95em}
.cert-no{font-family:'Montserrat', monospace;font-weight:700;color:#1b5e20;font-size:1.05em}

.cert-codes{display:flex;justify-content:center;align-items:center;gap:24px;margin-top:16px;flex-wrap:wrap}
.cert-codes canvas{width:100px!important;height:100px!important}
.cert-codes svg{width:200px!important;height:50px!important}

/* ===== PRINT STYLES ===== */
@media print {
  .form-section, .cert-actions, #certForm {
    display: none !important;
  }
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 15mm 0 0 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important; 
    print-color-adjust: exact !important;
  }
  .app-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
  }
  .cert-section {
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
  }
  .certificate {
    width: 297mm !important;
    height: 210mm !important;
    zoom: 0.85 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 25px 40px !important;
    box-sizing: border-box !important;
    border: 10px double #1b5e20 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    page-break-before: avoid !important;
    position: relative !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .certificate * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  /* Slightly more compact sizing in print to prevent overflowing the page */
  .cert-logo {
    height: 78px !important;
  }
  .cert-logo-center {
    height: 94px !important;
  }
  .cert-logos {
    display: flex !important;
    justify-content: space-between !important;
    width: calc(100% + 40px) !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    margin-bottom: 12px !important;
  }
  .cert-header {
    margin-bottom: 10px !important;
  }
  .cert-header h1 {
    font-size: 2em !important;
    margin-bottom: 2px !important;
  }
  .cert-header h2 {
    font-size: 1.15em !important;
    margin-bottom: 4px !important;
  }
  .cert-subtitle {
    font-size: 0.95em !important;
  }
  .cert-text {
    font-size: 1.1em !important;
    line-height: 1.6 !important;
    margin-bottom: 10px !important;
    text-align: justify !important;
    text-indent: 30px !important;
  }
  .cert-photo {
    width: 250px !important;
    height: 250px !important;
  }
  .cert-photo-wrapper {
    margin: 8px auto !important;
  }
  .cert-bottom {
    margin-top: 10px !important;
    padding-top: 8px !important;
  }
  .cert-codes canvas {
    width: 70px !important;
    height: 70px !important;
  }
  .cert-codes svg {
    width: 140px !important;
    height: 35px !important;
  }

  @page {
    size: landscape;
    margin: 0;
  }
}

/* ===== ADMIN PAGE ===== */
.admin-body{background:#f5f5f5}

.login-wrapper{display:flex;align-items:center;justify-content:center;min-height:100vh}
.login-card{background:#fff;border-radius:16px;padding:40px;width:400px;max-width:90%;box-shadow:0 4px 24px rgba(0,0,0,0.1);border-top:5px solid #2e7d32}
.login-header{text-align:center;margin-bottom:28px}
.login-header h2{color:#1b5e20;margin-top:10px}
.login-logo{height:60px;width:auto}

.error-msg{color:#d32f2f;font-size:0.9em;text-align:center;margin-bottom:12px}

.admin-dashboard{max-width:1300px;margin:0 auto;padding:0 20px 30px}
.admin-topbar{display:flex;align-items:center;justify-content:space-between;background:#fff;padding:14px 24px;border-radius:0 0 14px 14px;box-shadow:0 2px 12px rgba(0,0,0,0.06);margin-bottom:24px;flex-wrap:wrap;gap:12px}
.admin-topbar h1{font-size:1.2em;color:#1b5e20}
.admin-topbar-logo{height:40px;width:auto}
.admin-topbar-right{display:flex;align-items:center;gap:16px}
.admin-topbar-right span{color:#666;font-size:0.9em}
.btn-logout{padding:8px 18px;background:#d32f2f;color:#fff;border:none;border-radius:8px;cursor:pointer;font-weight:600;font-size:0.9em;transition:background .2s}
.btn-logout:hover{background:#b71c1c}

.admin-stats{background:#fff;border-radius:12px;padding:18px 24px;box-shadow:0 2px 12px rgba(0,0,0,0.06);margin-bottom:20px;font-size:1em;color:#333;font-weight:600;border-left:4px solid #2e7d32}

.admin-table-wrapper{background:#fff;border-radius:14px;box-shadow:0 2px 12px rgba(0,0,0,0.06);overflow-x:auto}
.admin-table{width:100%;border-collapse:collapse;min-width:800px}
.admin-table th{background:#1b5e20;color:#fff;padding:14px 12px;font-size:0.9em;text-align:left;white-space:nowrap}
.admin-table td{padding:12px;border-bottom:1px solid #e0e0e0;font-size:0.92em;color:#333}
.admin-table tr:hover{background:#f1f8e9}
.admin-table .td-photo{width:70px}
.admin-table .td-photo img{width:44px;height:44px;border-radius:50%;object-fit:cover;border:2px solid #a5d6a7}
.admin-table .td-photo .no-photo{width:44px;height:44px;border-radius:50%;background:#e0e0e0;display:flex;align-items:center;justify-content:center;font-size:0.7em;color:#999}
.btn-view,.btn-delete{padding:6px 14px;border:none;border-radius:6px;font-size:0.85em;font-weight:600;cursor:pointer;transition:all .2s;margin:2px}
.btn-view{background:#2e7d32;color:#fff}
.btn-view:hover{background:#1b5e20}
.btn-delete{background:#d32f2f;color:#fff}
.btn-delete:hover{background:#b71c1c}

/* ===== MODAL ===== */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:1000;display:flex;align-items:flex-start;justify-content:center;padding:30px 20px;overflow-y:auto}
.modal-content{position:relative;width:1100px;max-width:100%}
.modal-close{position:absolute;top:10px;right:18px;font-size:2em;color:#333;cursor:pointer;z-index:10}
.modal-close:hover{color:#d32f2f}
.cert-modal{background:#fff}

/* ===== NEW BOTTOM LAYOUT ===== */
.cert-bottom{display:flex;justify-content:space-between;align-items:flex-end;margin-top:14px;padding-top:10px;border-top:1px dashed #a5d6a7;gap:10px;flex-wrap:wrap}
.cert-bottom-left{text-align:left;font-size:.85em}
.cert-bottom-left .cert-no{font-family:'Courier New',monospace;font-weight:700;color:#1b5e20;font-size:.95em}
.cert-bottom-right{text-align:right}
.cert-codes{display:flex;justify-content:center;align-items:center;gap:12px;flex-wrap:wrap}
.cert-codes canvas{width:80px!important;height:80px!important}
.cert-codes svg{width:160px!important;height:40px!important}
.cert-signature{display:flex;flex-direction:column;align-items:center;gap:4px;margin-top:8px}
.cert-signature img{width:120px;height:auto;background:transparent !important}
.cert-signature-text{text-align:center;font-size:.8em;color:#333;line-height:1.3}
.cert-signature-text strong{display:block;font-size:.9em;color:#1b5e20}

/* ===== WATERMARK STYLING ===== */
.cert-watermark {position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0.05;width:950px;height:950px;pointer-events:none;z-index:1}
.cert-watermark img {width:100%;height:100%;object-fit:contain;background:transparent !important}
.cert-logos, .cert-header, .cert-body, .cert-bottom {position:relative;z-index:2}

/* ===== RESPONSIVE & SCREEN SCALING ===== */
@media screen and (max-width: 1040px) {
  .certificate {
    zoom: calc((100vw - 40px) / 1000);
    width: 1000px !important;
    max-width: none !important;
  }
  .modal-overlay {
    padding: 15px 10px;
  }
  .modal-content {
    width: 100%;
  }
}
@media screen and (max-width: 600px) {
  .app-container {
    padding: 10px;
  }
  .form-card {
    padding: 24px 16px;
  }
  .form-header {
    gap: 8px;
    margin-bottom: 20px;
  }
  .form-header h2 {
    font-size: 1.15em;
  }
  .form-logo {
    height: 40px;
  }
  .cert-actions {
    gap: 8px;
  }
  .btn-print, .btn-new {
    padding: 10px 20px;
    font-size: 0.9em;
    flex-grow: 1;
    text-align: center;
  }
}

