:root{
  --bg:#0f1724;
  --card-bg: rgba(255,255,255,0.06);
  --accent:#2b8cff;
  --gold:#c39b3b;
  --green:#1ea67a;
  --mono:#333;
  --white: #ffffff;
}

*{box-sizing:border-box}
body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(180deg,#071029 0%, #0f1724 100%);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px;
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  text-align: center;
}

.app {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  box-sizing: border-box;
}

header{
  text-align:center;
  margin-bottom:18px;
}

header h1{margin:0 0 6px 0;font-weight:600}
header p{margin:0;color:#b8c6d8}

main {
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  padding: 0 5px;
  box-sizing: border-box;
}

@media (min-width: 992px) {
  main {
    flex-direction: row;
    align-items: flex-start;
  }
}

/* Controls */
.controls{
  width: 100%;
  max-width: 500px;
  background:var(--card-bg);
  border-radius:12px;
  padding:16px;
  box-shadow:0 6px 18px rgba(2,6,23,0.6);
  border:1px solid rgba(255,255,255,0.08);
  margin: 0 auto;
}

@media (min-width: 992px) {
  .controls {
    width: 320px;
    margin: 0;
  }
}

.controls label{display:block;margin-bottom:10px;font-size:13px;color:#d7e5ff}
.controls input[type="text"],
.controls input[type="file"]{
  width:100%;
  padding:10px 8px;
  margin-top:6px;
  border-radius:8px;
  border: none;
  background: rgba(255,255,255,0.06);
  color:var(--white);
  outline: none;
}

/* Theme selector styles */
.controls select{
  width:100%;
  padding:10px 8px;
  margin-top:6px;
  border-radius:8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0, 0, 0, 0.3);
  color: #e5e7eb;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.controls select:hover {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255,255,255,0.2);
}

.controls select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Style the dropdown options */
.controls select option {
  background: #1e293b;
  color: #e5e7eb;
  padding: 8px;
}

/* Style the dropdown arrow */
.controls select {
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23e5e7eb%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem top 50%;
  background-size: 0.65rem auto;
  padding-right: 2.5rem;
}

.buttons{display:flex;gap:10px;margin-top:12px}
.buttons button{
  flex:1;
  padding:10px;
  border-radius:8px;
  border:none;
  cursor:pointer;
  font-weight:600;
  background:var(--accent);
  color:#fff;
  transition:transform .14s ease, box-shadow .14s;
}
.buttons button:hover{transform:translateY(-3px);box-shadow:0 10px 30px rgba(43,140,255,0.18)}
.buttons button:nth-child(2){background:#0ea5a4}

/* Preview */
.preview-wrap{flex:1;display:flex;flex-direction:column;align-items:center}
.hint{color:#9fb1d4;font-size:13px;margin-top:8px}

/* Certificate */
.certificate {
  width: 95%;
  max-width: 800px;
  height: auto;
  aspect-ratio: 1.4;
  min-height: 300px;
  border-radius: 12px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  box-shadow: 0 12px 40px rgba(2,6,23,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  transform-origin: center;
  box-sizing: border-box;
  overflow: hidden;
}

/* Adjust for larger screens */
@media (min-width: 768px) {
  .certificate {
    transform: scale(1);
    padding: 10px;
    min-height: 400px;
  }
}

.cert-border{
  width:100%;
  height:100%;
  padding:18px;
  border:10px solid rgba(255,255,255,0.07);
  border-radius:8px;
  background: #fff;
}

.cert-inner {
  width: 100%;
  height: 100%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  background: linear-gradient(180deg, #fff, #fdfdfd);
  overflow: hidden;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .cert-inner {
    padding: 25px;
  }
}

/* Header */
.cert-header{
  display:flex;
  align-items:center;
  gap:18px;
}
.logo-placeholder{
  width:88px;height:88px;border-radius:8px;background:linear-gradient(135deg,#e6eefc,#dbe8ff);display:flex;align-items:center;justify-content:center;color:#0e2a66;font-weight:700;font-size:13px;overflow:hidden;
}
.cert-header h2{
  margin: 0;
  font-size: 16px;
  color: #0b2540;
  font-weight: 700;
  word-wrap: break-word;
}

@media (min-width: 768px) {
  .cert-header h2 {
    font-size: 20px;
  }
}

/* Body */
.cert-body {
  text-align: center;
  padding: 5px 0;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.cert-sub{margin:0;color:#334155;font-size:14px}
#cert-name{
  margin: 8px 0 6px 0;
  font-size: 24px;
  color: #071231;
  letter-spacing: 0.6px;
  word-wrap: break-word;
  padding: 0 10px;
}

@media (min-width: 768px) {
  #cert-name {
    margin: 14px 0 8px 0;
    font-size: 36px;
  }
}
#cert-event{
  margin: 0;
  color: #334155;
  font-size: 14px;
  padding: 0 10px;
  word-wrap: break-word;
}

@media (min-width: 768px) {
  #cert-event {
    font-size: 16px;
  }
}

/* Footer */
.cert-footer{display:flex;justify-content:space-between;align-items:center;margin-top:8px}
.cert-footer .small{margin:0;color:#4b5563;font-size:12px;font-weight:500}
#cert-date{color:#1f2937;font-weight:600;font-size:14px}
.signature-line{margin-top:6px;border-top:1px solid #cbd5e1;padding-top:6px;color:#1f2937;font-weight:600}

/* Themes */
.theme-blue .cert-inner {
  background: linear-gradient(180deg, #f0f7ff, #e6f1ff);
  border: 1px solid rgba(43, 140, 255, 0.3);
}
.theme-blue .cert-border {
  border: 10px solid rgba(43, 140, 255, 0.2);
  background: #f8fbff;
}
.theme-blue .cert-header h2 { color: #1a56db; }
.theme-blue #cert-name { color: #1a3a8f; }

.theme-gold .cert-inner {
  background: linear-gradient(180deg, #fffbf0, #fff9e6);
  border: 1px solid rgba(195, 155, 59, 0.4);
}
.theme-gold .cert-border {
  border: 10px solid rgba(195, 155, 59, 0.3);
  background: #fffcf5;
}
.theme-gold .cert-header h2 { color: #b7791f; }
.theme-gold #cert-name { color: #975a16; }
.theme-gold .cert-sub,
.theme-gold #cert-event { color: #5f370e; }

.theme-green .cert-inner {
  background: linear-gradient(180deg, #f0fff4, #e6ffed);
  border: 1px solid rgba(30, 166, 122, 0.4);
}
.theme-green .cert-border {
  border: 10px solid rgba(30, 166, 122, 0.3);
  background: #f0fff4;
}
.theme-green .cert-header h2 { color: #0e9f6e; }
.theme-green #cert-name { color: #046c4e; }
.theme-green .cert-sub,
.theme-green #cert-event { color: #03543f; }

.theme-simple .cert-inner {
  background: #ffffff;
  border: 1px solid #e5e7eb;
}
.theme-simple .cert-border {
  border: 10px solid #f3f4f6;
  background: #ffffff;
}
.theme-simple .cert-header h2 { color: #111827; }
.theme-simple #cert-name { color: #111827; }
.theme-simple .cert-sub,
.theme-simple #cert-event { color: #4b5563; }

/* Footer */
footer {
  margin-top: 40px;
  text-align: center;
  padding: 20px 0;
  color: #94a3b8;
  font-size: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.footer-text {
  font-size: 15px;
  color: #cbd5e1;
}

.footer-text strong {
  color: #60a5fa;
  font-weight: 600;
}

.social-links {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.social-icon {
  color: #94a3b8;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.social-icon:hover {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
  transform: translateY(-2px);
}

.footer-copyright {
  font-size: 13px;
  color: #64748b;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Responsive */
@media (max-width:1000px){
  main{flex-direction:column}
  .controls{width:100%}
  .certificate{width:100%;height:420px}
}
@media (max-width: 768px) {
  .certificate {
    transform: none;
    min-height: auto;
    width: 100%;
    max-width: 100%;
    padding: 5px;
    margin: 10px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    left: 0;
    right: 0;
  }
  
  #cert-name {
    font-size: 20px !important;
    margin: 5px 0 !important;
    line-height: 1.2;
  }
  
  .cert-header h2 {
    font-size: 14px !important;
    line-height: 1.3;
  }
  
  .cert-sub, #cert-event {
    font-size: 13px !important;
    padding: 0 5px !important;
  }
  
  .cert-footer {
    margin-top: 10px !important;
  }
  
  .cert-footer .small, #cert-date {
    font-size: 11px !important;
  }
  
  .signature-line {
    font-size: 12px !important;
  }
  
  .logo-placeholder {
    width: 60px !important;
    height: 60px !important;
    font-size: 10px !important;
  }
}

/* For very small devices */
@media (max-width: 400px) {
  .certificate {
    transform: none;
    min-height: auto;
    width: 100%;
    max-width: 100%;
    padding: 5px;
    margin: 0 auto;
    position: relative;
    left: 0;
    right: 0;
  }
  
  #cert-name {
    font-size: 20px !important;
  }
  
  body {
    padding: 10px 5px !important;
  }
}