/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cormorant Garamond', serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
    padding-top: 100px;
    line-height: 1.6;
}

/* ========================================
   NAVIGATION BAR
   ======================================== */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a4a2e 0%, #2d7a4d 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex;
    align-items: center;
}

.nav-title {
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.nav-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.nav-link.active {
    background: white;
    color: #1a4a2e;
    border-color: #d4af37;
}

.nav-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-btn-password {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.nav-btn-password:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-btn-logout {
    background: #dc3545;
    color: white;
}

.nav-btn-logout:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
}

@media (max-width: 768px) {
    body {
        padding-top: 140px;
    }

    .top-nav {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
    }

    .nav-left {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        text-align: center;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .nav-right {
        width: 100%;
        justify-content: center;
    }

    .nav-link {
        flex: 1;
        justify-content: center;
        font-size: 14px;
        padding: 8px 12px;
    }

    .nav-btn {
        font-size: 13px;
        padding: 8px 16px;
    }
}

/* ========================================
   FORM CONTAINER STYLES
   ======================================== */
.form-container {
    max-width: 600px;
    margin: 0 auto 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 40px;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #1a4a2e;
}

.form-logo {
    width: 80px;
    height: auto;
    margin-bottom: 15px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.form-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: #1a4a2e;
    margin-bottom: 5px;
}

.form-header p {
    font-size: 16px;
    color: #666;
}

/* ========================================
   FORM STYLES
   ======================================== */
.certificate-form {
    margin-bottom: 30px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    font-weight: 600;
    color: #1a4a2e;
    margin-bottom: 8px;
    font-size: 15px;
}

input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Cormorant Garamond', serif;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="date"]:focus {
    outline: none;
    border-color: #1a4a2e;
    box-shadow: 0 0 0 3px rgba(26, 74, 46, 0.1);
}

input[type="text"]::placeholder {
    color: #999;
}

/* ========================================
   BUTTON STYLES
   ======================================== */
.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.btn {
    flex: 1;
    min-width: 150px;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Cormorant Garamond', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #1a4a2e 0%, #2d7a4d 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0f2f1d 0%, #1a4a2e 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 74, 46, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #d4af37 0%, #f4d03f 100%);
    color: #1a4a2e;
}

.btn-secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #c49f2f 0%, #d4af37 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.3);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-reset {
    background: #f5f5f5;
    color: #666;
    flex: 0 1 auto;
}

.btn-reset:hover {
    background: #e0e0e0;
}

/* ========================================
   FORM FOOTER
   ======================================== */
.form-footer {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #d4af37;
}

.form-footer p {
    margin-bottom: 10px;
    color: #1a4a2e;
    font-size: 15px;
}

.form-footer ol {
    margin-left: 20px;
    color: #666;
    font-size: 14px;
}

.form-footer ol li {
    margin-bottom: 5px;
}

.print-reminder {
    margin-top: 20px;
    padding: 15px;
    background: #fff9e6;
    border: 2px solid #d4af37;
    border-radius: 8px;
}

.print-reminder p {
    color: #1a4a2e;
    margin-bottom: 8px;
    font-size: 14px;
}

.print-reminder p:last-child {
    margin-bottom: 0;
}

.print-reminder em {
    color: #666;
    font-size: 13px;
}

/* ========================================
   CERTIFICATE PREVIEW SECTION
   ======================================== */
.certificate-preview {
    max-width: 1200px;
    margin: 0 auto;
    transition: all 0.5s ease;
}

.certificate-preview.hidden {
    display: none;
}

.preview-header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeIn 0.6s ease;
}

.preview-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    color: #1a4a2e;
    margin-bottom: 5px;
}

.preview-header p {
    color: #666;
    font-size: 16px;
}

/* ========================================
   CERTIFICATE STYLES
   ======================================== */
.certificate {
    position: relative;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    aspect-ratio: 297 / 210;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
    animation: zoomIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Background Image */
.certificate-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://images.pexels.com/photos/3752402/pexels-photo-3752402.jpeg?auto=compress&cs=tinysrgb&w=1920');
    background-size: cover;
    background-position: center;
    opacity: 0.12;
    z-index: 1;
    filter: brightness(1.1) contrast(0.9);
}

/* Borders */
.certificate-border {
    position: absolute;
    top: 25px;
    left: 25px;
    right: 25px;
    bottom: 25px;
    border: 3px solid #d4af37;
    z-index: 2;
    border-radius: 2px;
}

.certificate-inner-border {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 1px solid #1a4a2e;
    z-index: 3;
}

/* Content */
.certificate-content {
    position: relative;
    z-index: 10;
    padding: 40px 70px;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Logo */
.certificate-logo {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.certificate-logo img {
    width: 85px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.8));
}

/* Title */
.certificate-title {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 700;
    color: #1a4a2e;
    letter-spacing: 2px;
    margin-bottom: 6px;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* Subtitle */
.certificate-subtitle {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 400;
    color: #d4af37;
    margin-bottom: 20px;
    font-style: italic;
    flex-shrink: 0;
}

/* Main Content Area */
.certificate-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
}

/* Intro */
.certificate-intro {
    font-size: 17px;
    color: #333;
    margin-bottom: 12px;
}

/* Guest Name */
.certificate-name {
    font-family: 'Playfair Display', serif;
    font-size: 42px;
    font-weight: 700;
    color: #1a4a2e;
    margin: 12px 0 18px;
    text-decoration: underline;
    text-decoration-color: #d4af37;
    text-decoration-thickness: 2px;
    text-underline-offset: 8px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Details */
.certificate-details {
    font-size: 18px;
    color: #333;
    margin-bottom: 18px;
    line-height: 1.6;
}

/* Info Box */
.certificate-info {
    display: inline-block;
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid #d4af37;
    border-radius: 4px;
    padding: 12px 35px;
    margin: 15px 0;
}

.certificate-info p {
    font-size: 15px;
    color: #1a4a2e;
    margin: 4px 0;
}

.certificate-info strong {
    font-weight: 600;
    margin-right: 10px;
}

/* Quote */
.certificate-quote {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    font-style: italic;
    color: #666;
    margin: 18px auto;
    max-width: 500px;
}

/* Signature */
.certificate-signature {
    margin-top: 25px;
    flex-shrink: 0;
    padding-bottom: 5px;
}

.signature-line {
    width: 240px;
    height: 2px;
    background: #333;
    margin: 0 auto 8px;
}

.signature-title {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 3px;
}

.signature-estate {
    font-size: 13px;
    color: #666;
}

/* Decorative Corners */
.corner {
    position: absolute;
    width: 35px;
    height: 35px;
    border-color: #d4af37;
    z-index: 5;
}

.corner-tl {
    top: 18px;
    left: 18px;
    border-top: 3px solid;
    border-left: 3px solid;
}

.corner-tr {
    top: 18px;
    right: 18px;
    border-top: 3px solid;
    border-right: 3px solid;
}

.corner-bl {
    bottom: 18px;
    left: 18px;
    border-bottom: 3px solid;
    border-left: 3px solid;
}

.corner-br {
    bottom: 18px;
    right: 18px;
    border-bottom: 3px solid;
    border-right: 3px solid;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    body {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .form-container,
    .preview-header {
        display: none !important;
    }

    .certificate-preview {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        page-break-after: avoid;
        background: white !important;
    }

    .certificate {
        width: 297mm !important;
        height: 210mm !important;
        max-width: none !important;
        aspect-ratio: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        page-break-inside: avoid;
        margin: 0 !important;
        padding: 0 !important;
        position: relative;
        background: white !important;
    }

    /* CRITICAL: Ensure background image prints */
    .certificate-background {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-image: url('https://images.pexels.com/photos/3752402/pexels-photo-3752402.jpeg?auto=compress&cs=tinysrgb&w=1920') !important;
        background-size: cover !important;
        background-position: center !important;
        opacity: 0.12 !important;
        z-index: 1 !important;
        filter: brightness(1.1) contrast(0.9) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ensure borders print with color */
    .certificate-border {
        position: absolute !important;
        top: 25px !important;
        left: 25px !important;
        right: 25px !important;
        bottom: 25px !important;
        border: 3px solid #d4af37 !important;
        z-index: 2 !important;
        border-radius: 2px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .certificate-inner-border {
        position: absolute !important;
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        border: 1px solid #1a4a2e !important;
        z-index: 3 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ensure decorative corners print */
    .corner {
        position: absolute !important;
        width: 35px !important;
        height: 35px !important;
        border-color: #d4af37 !important;
        z-index: 5 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .corner-tl {
        top: 18px !important;
        left: 18px !important;
        border-top: 3px solid #d4af37 !important;
        border-left: 3px solid #d4af37 !important;
    }

    .corner-tr {
        top: 18px !important;
        right: 18px !important;
        border-top: 3px solid #d4af37 !important;
        border-right: 3px solid #d4af37 !important;
    }

    .corner-bl {
        bottom: 18px !important;
        left: 18px !important;
        border-bottom: 3px solid #d4af37 !important;
        border-left: 3px solid #d4af37 !important;
    }

    .corner-br {
        bottom: 18px !important;
        right: 18px !important;
        border-bottom: 3px solid #d4af37 !important;
        border-right: 3px solid #d4af37 !important;
    }

    .certificate-content {
        padding: 40px 70px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ensure all colors print */
    .certificate-title {
        color: #1a4a2e !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .certificate-subtitle {
        color: #d4af37 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .certificate-name {
        color: #1a4a2e !important;
        text-decoration-color: #d4af37 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .certificate-info {
        background: rgba(212, 175, 55, 0.1) !important;
        border: 1px solid #d4af37 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .certificate-info p {
        color: #1a4a2e !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .certificate-logo img {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Force all elements to print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */
@media (max-width: 768px) {
    .form-container {
        padding: 30px 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        min-width: auto;
    }

    .certificate {
        margin: 0 -20px;
        border-radius: 0;
    }

    .certificate-content {
        padding: 25px 35px;
    }

    .certificate-title {
        font-size: 22px;
        letter-spacing: 1px;
    }

    .certificate-subtitle {
        font-size: 18px;
    }

    .certificate-name {
        font-size: 30px;
        min-height: 38px;
    }

    .certificate-details,
    .certificate-intro {
        font-size: 15px;
    }

    .certificate-quote {
        font-size: 14px;
    }

    .certificate-info {
        padding: 10px 25px;
    }

    .certificate-info p {
        font-size: 13px;
    }

    .certificate-logo img {
        width: 70px;
    }

    .form-footer ol {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .certificate-content {
        padding: 20px 22px;
    }

    .certificate-title {
        font-size: 16px;
        letter-spacing: 0.5px;
    }

    .certificate-subtitle {
        font-size: 14px;
    }

    .certificate-name {
        font-size: 22px;
        min-height: 30px;
    }

    .certificate-logo img {
        width: 55px;
    }

    .certificate-intro,
    .certificate-details {
        font-size: 13px;
    }

    .certificate-quote {
        font-size: 12px;
    }

    .certificate-info {
        padding: 8px 20px;
    }

    .certificate-info p {
        font-size: 11px;
    }

    .signature-title {
        font-size: 13px;
    }

    .signature-estate {
        font-size: 11px;
    }
}