/* 
   Custom CSS for Medical Certificate Generator 
   Tailwind is used for the majority of styling, these are specific overrides and template structures.
*/
 
/* Scoped Reset for Medical Certificate Generator */
#med-cert-gen-container *,
#med-cert-gen-container *::before,
#med-cert-gen-container *::after {
    box-sizing: border-box;
}
 
#med-cert-gen-container img {
    display: block;
    max-width: 100%;
}
 
#med-cert-gen-container button,
#med-cert-gen-container select,
#med-cert-gen-container input,
#med-cert-gen-container textarea {
    margin: 0;
    font-family: inherit;
}

/* Custom Scrollbar for the left panel */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* tailwind slate-300 */
    border-radius: 10px;
}
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #475569; /* tailwind slate-600 */
}

/* Form Styles */
.form-input {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db; /* gray-300 */
    background-color: #ffffff;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.form-input:focus {
    border-color: #2563eb; /* primary */
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #2563eb;
}

.dark .form-input {
    border-color: #000000; /* gray-600 */
    background-color: #000000; /* gray-700 */
    color: #ffffff;
}

.dark .form-input::placeholder {
    color: #9ca3af; /* gray-400 */
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.dark select.form-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

.template-btn {
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb; /* gray-200 */
    background-color: #ffffff;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 500;
    color: #000000; /* gray-700 */
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
    cursor: pointer;
}

.template-btn:hover {
    border-color: #2563eb; /* primary */
}

.dark .template-btn {
    border-color: #000000; /* gray-600 */
    background-color: #1f2937; /* gray-800 */
    color: #d1d5db; /* gray-300 */
}

.dark .template-btn:hover {
    border-color: #2563eb;
}

.template-btn.active {
    border-color: #2563eb;
    background-color: #eff6ff; /* blue-50 */
    color: #2563eb;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.dark .template-btn.active {
    background-color: rgba(30, 58, 138, 0.3); /* blue-900/30 */
    border-color: #2563eb;
    color: #60a5fa; /* blue-400 */
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Section Containers with Borders */
.form-section {
    border: 2px solid #f5f7ee !important;
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    background-color: #ffffff !important;
    box-shadow: 0 4px 12px #f5f7ee !important;
    transition: box-shadow 0.2s;
}

.form-section:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.dark .form-section {
    border-color: #000000; /* gray-700 */
    background-color: rgba(31, 41, 55, 0.5); /* gray-800/50 */
}

.form-section h3 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #2563eb; /* primary */
    border-bottom: 1px solid #f3f4f6; /* gray-100 */
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dark .form-section h3 {
    color: #60a5fa; /* blue-400 */
    border-color: #000000; /* gray-700 */
}

/* Instructions Box */
.instructions-container {
    background-color: #ffffff !important;
    border: 2px solid #f5f7ee !important;
    box-shadow: 0 4px 12px #f5f7ee !important;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.dark .instructions-container {
    background-color: rgba(30, 58, 138, 0.1); /* blue-900/10 */
    border-color: rgba(30, 58, 138, 0.3); /* blue-900/30 */
}

.instruction-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #000000; /* gray-600 */
    margin-bottom: 0.5rem;
}

.instruction-step:last-child {
    margin-bottom: 0;
}

.dark .instruction-step {
    color: #9ca3af; /* gray-400 */
}

.instruction-step i {
    color: #2563eb;
    margin-top: 0.125rem;
}

/* Premium Button Enhancements */
.btn-premium {
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
}

.btn-premium:active {
    transform: scale(0.98);
}

.btn-premium:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-0.125rem);
}

.btn-premium::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-premium:hover::after {
    opacity: 1;
}

/* Color Button Labels */
.color-btn-label {
    font-size: 10px;
    color: #000000; /* gray-500 */
    margin-top: 0.25rem;
    display: block;
    text-align: center;
}

.dark .color-btn-label {
    color: #9ca3af; /* gray-400 */
}

/* 
=========================================
TEMPLATE STYLES 
=========================================
*/

/* Base Certificate Defaults */
#certificate-preview {
    color: #111827; /* Enforce dark text for saving purposes, ignoring app dark mode */
}
#certificate-preview .data-field {
    border-bottom: 1px dotted #9ca3af;
    display: inline-block;
    min-width: 50px;
    text-align: center;
    padding: 0 4px;
}
.cert-inner {
    padding: 3rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Template 1: Classic (Default) */
.template-classic .cert-inner {
    border: 12px solid double #4b5563; /* Double border simulation */
    box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 6px #1f2937;
    margin: 1rem;
    padding: 3rem;
    background: #ffffff;
}
.template-classic h2 {
    font-family: 'Playfair Display', serif;
    color: #1f2937;
    border-bottom: 2px solid #1f2937;
    display: inline-block;
    padding-bottom: 0.5rem;
}
.template-classic .cert-body {
    font-family: 'Inter', sans-serif;
    font-size: 1.125rem;
}

/* Template 2: Minimal Modern */
.template-modern .cert-inner {
    padding: 4rem;
    background: #ffffff;
}
.template-modern .cert-header {
    border-bottom: 4px solid #2563eb;
    padding-bottom: 2rem;
}
.template-modern h2 {
    font-family: 'Inter', sans-serif;
    color: #2563eb;
    font-weight: 900;
    letter-spacing: 0.1em;
}
.template-modern .cert-body {
    font-family: 'Roboto', sans-serif;
    font-size: 1.125rem;
    line-height: 2;
}
.template-modern .data-field {
    border-bottom: 2px solid #e5e7eb;
}

/* Template 3: Hospital Letterhead */
.template-letterhead .cert-inner {
    padding: 3rem 4rem;
    background-color: #fafaf9; /* warm white */
    border-top: 20px solid #1e3a8a; /* deep blue top bar */
}
.template-letterhead .cert-header {
    border-bottom: none;
    flex-direction: column;
    text-align: center;
    align-items: center;
    margin-bottom: 3rem;
}
.template-letterhead .cert-header > div:first-child {
    flex-direction: column;
    text-align: center;
}
.template-letterhead #preview-hospital-name {
    font-size: 2.25rem;
    color: #1e3a8a;
    font-family: 'Playfair Display', serif;
}
.template-letterhead .cert-header > div:last-child {
    position: absolute;
    top: 3rem;
    right: 4rem;
}

/* Template 4: Handwritten Note */
.template-handwritten .cert-inner {
    padding: 4rem 3rem;
    background: #fffdf0; /* pale yellow tint */
    background-image: linear-gradient(#e1e7ec 1px, transparent 1px);
    background-size: 100% 2.5rem; /* line ruling */
    background-position: 0 4rem;
}
.template-handwritten.no-lines .cert-inner {
    background-image: none;
}
.template-handwritten .cert-header {
    border-bottom: none;
    font-family: 'Roboto', sans-serif;
}
.template-handwritten h2 {
    font-family: 'Roboto', sans-serif;
    margin-bottom: 1rem;
    text-decoration: underline;
}
.template-handwritten .cert-body {
    font-family: 'Caveat', cursive;
    font-size: 1.75rem;
    line-height: 2.5rem; /* Match the background grid */
}
.template-handwritten .data-field {
    border-bottom: none;
    font-weight: inherit;
}
.template-handwritten .cert-footer h3 {
    font-family: 'Caveat', cursive;
    font-size: 2rem;
}


/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }
    #certificate-preview, #certificate-preview * {
        visibility: visible;
    }
    #certificate-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        box-shadow: none;
    }
}
