:root {
    --primary-color: #1a2438;
    --secondary-color: #f25e38;
    --background-color: #f0f4f8;
    --card-background: #ffffff;
    --border-color: #e0e6ed;
    --text-color: #333333;
    --placeholder-color: #999999;
    --accent-color: #f25e38;
    --success-color: #28a745;
    --error-color: #dc3545;
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

*, *::before, *::after { box-sizing: inherit; }

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image: linear-gradient(135deg, #e4ebf0 0%, #dbe4ee 100%);
}

h1, h2, h3 { color: var(--primary-color); font-weight: 600; }
h1 { font-size: 2.5rem; }
h2 { font-size: 1.5rem; }

header {
    background-color: var(--primary-color);
    padding: 15px 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--box-shadow);
}
.logo-container { position: absolute; left: 40px; }
.logo { width: 100px; height: auto; }
.header-title {
    color: var(--accent-color);
    margin: 0;
    font-size: 30px;
    text-align: center;
}

.main-content {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    width: 100%;
}

#cards-wrapper {
    display: grid;
    grid-template-columns: minmax(340px, 560px);
    grid-auto-flow: row;
    justify-content: center;
    justify-items: center;
    align-items: center;
    gap: 28px;
    width: 100%;
    max-width: 1200px;
}

#cards-wrapper.show-signature {
    grid-auto-flow: column;
    grid-template-columns: minmax(360px, 560px) minmax(420px, 720px);
    justify-content: center;
    justify-items: center;
    align-items: center;
    gap: 24px;
}

@media (max-width: 980px){
    #cards-wrapper,
    #cards-wrapper.show-signature {
        grid-auto-flow: row;
        grid-template-columns: minmax(300px, 1fr);
        justify-items: stretch;
        gap: 20px;
    }
}

@media (min-width: 992px) {
    #cards-wrapper { transition: all 0.35s ease-in-out; }
}

.card {
    background-color: var(--card-background);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 500px;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
}

.signature-preview {
    display: none;
    position: relative;
    flex-shrink: 0;
    text-align: left;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 200px;
}

.signature-preview.card {
    max-width: 680px;
    width: 100%;
    padding: 0;
}

.signature-preview .signature-wrapper {
    position: relative;
    padding: 30px;
}

.signature-preview .signature-placeholder {
    color: var(--placeholder-color);
    font-style: italic;
    font-weight: 300;
    text-align: center;
    margin: 0;
}

.signature-preview table {
    width: 100%;
    border-collapse: collapse;
}
.signature-preview table td {
    text-align: left;
    vertical-align: middle;
}
.signature-preview img {
    max-width: none;
    height: auto;
    border: 0;
    display: inline-block;
}

.form-title { text-align: center; margin-bottom: 5px; }
.form-info {
    font-size: 11px;
    color: var(--placeholder-color);
    margin-bottom: 25px;
    text-align: right;
}
.required-icon { color: var(--error-color); }
.input-group { margin-bottom: 20px; }

.label-required::after {
    content: " *";
    color: var(--error-color);
    font-size: 0.9em;
}
label { display: block; margin-bottom: 8px; font-weight: 500; }

.input-wrapper { position: relative; }
.input-wrapper .icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: var(--placeholder-color);
    transition: color 0.3s ease;
}

input, select {
    width: 100%;
    padding: 12px 12px 12px 45px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: var(--background-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
input::placeholder { color: var(--placeholder-color); }

input:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(209, 112, 0, 0.2);
    background-color: var(--card-background);
}
.input-wrapper:focus-within .icon { color: var(--accent-color); }

input.readonly { cursor: not-allowed; background-color: #e9ecef; }

.error-message {
    color: var(--error-color);
    font-size: 0.8rem;
    margin-top: 5px;
    display: none;
    font-weight: 500;
}

.email-split {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.email-user-wrapper { flex: 1 1 260px; }
.email-at {
    color: var(--primary-color);
    font-weight: 600;
    opacity: 0.9;
}
.email-domain-text {
    color: var(--accent-color);
    font-weight: 600;
    white-space: nowrap;
}
.domain-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.domain-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.domain-pill input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.domain-pill span {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 999px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.domain-pill input:checked + span {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(209, 112, 0, 0.15);
    font-weight: 600;
}

.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: min(100%, 300px);
    margin: 0 auto;
    padding: 14px 20px;
    border: none;
    border-radius: 50px;
    background-color: var(--accent-color);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(209, 112, 0, 0.4);
}
.generate-btn:hover {
    background-color: #e68500;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(209, 112, 0, 0.5);
}

#signatureOutput .signature-wrapper { position: relative; }

.sig-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 30;
}

.sig-action {
    position: relative;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background-color: #ffffff;
    backdrop-filter: blur(5px);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.sig-action:hover {
    background-color: var(--primary-color);
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}
.sig-action:hover i { color: #fff; }
.sig-action i {
    font-size: 14px;
    color: #1a2438;
    transition: color 0.2s ease, opacity 0.2s ease;
}
.sig-action .fa-circle-check { position: absolute; opacity: 0; transform: scale(0.8); }
.sig-action.copied .fa-copy,
.sig-action.copied .fa-code { opacity: 0; }
.sig-action.copied .fa-circle-check {
    opacity: 1; color: var(--success-color); transform: scale(1.2);
}
.sig-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    background: var(--primary-color);
    color: #fff;
    padding: 4px 8px;
    border-radius: 5px;
    display: none;
    white-space: nowrap;
    z-index: 10;
}
.sig-action:hover .sig-tooltip { display: block; }

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
}
.toast {
    background-color: var(--primary-color);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.5s ease-out, transform 0.3s ease-out;
    transform: translateX(100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { background-color: var(--success-color); }
.toast.error { background-color: var(--error-color); }
.toast .close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 10px;
    transition: transform 0.2s;
}
.toast .close-btn:hover { transform: rotate(90deg); }

footer {
    padding: 15px 40px;
    background-color: var(--primary-color);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.1);
}
.footer-logo {
    width: 20px;
    height: auto;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.version {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    margin: 0;
}

@media (max-width: 768px) {
    header { flex-direction: column; padding: 20px; }
    .logo-container { position: static; margin-bottom: 10px; }
    .header-title { font-size: 1.5rem; }
    .main-content { padding: 20px; }
    #cards-wrapper { grid-template-columns: 1fr; }
}

@media (min-width: 992px) {
    #cards-wrapper {
        transition: all 0.5s ease-in-out;
    }
    #cards-wrapper.show-signature {
        grid-template-columns: clamp(380px, 48vw, 720px) clamp(380px, 48vw, 720px);
        gap: 40px;
    }
}

@media (max-width: 980px){
    #cards-wrapper,
    #cards-wrapper.show-signature {
        grid-template-columns: 1fr;
    }
}
