/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.quick-actions {
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.university-logo, .innovation-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.university-logo {
    height: 70px;
}

.innovation-logo {
    height: 55px;
}

.logo-icon {
    font-size: 3rem;
    color: #667eea;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-text h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.header-text p {
    font-size: 1.1rem;
    color: #666;
    font-weight: 500;
}

.header-subtitle h2 {
    font-size: 1.8rem;
    color: #444;
    font-weight: 600;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

/* Form Section */
.form-section {
    display: flex;
    flex-direction: column;
}

.form-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.form-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-card h3 i {
    color: #667eea;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 0.95rem;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: rgba(255, 255, 255, 1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Preview Section */
.preview-section {
    display: flex;
    flex-direction: column;
}

.preview-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: fit-content;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.preview-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-header h3 i {
    color: #667eea;
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.action-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Letter Preview */
.letter-preview {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    min-height: 400px;
    border: 1px solid #e1e5e9;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #999;
    text-align: center;
}

.placeholder i {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.placeholder p {
    font-size: 1.1rem;
}

/* Full Page A4 Letter Styles */
.letter-content {
    font-family: 'Times New Roman', serif;
    line-height: 1.5;
    color: #000;
    background: white;
    width: 210mm;
    height: 297mm;
    margin: 0 auto;
    padding: 12mm;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Full Page Header */
.letter-header {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.logo-left, .logo-right {
    flex: 0 0 auto;
}

.header-center {
    flex: 1;
    text-align: center;
    padding: 0 15px;
}

.header-logo {
    height: 70px;
    width: auto;
    object-fit: contain;
}

.university-name {
    font-size: 22px;
    font-weight: bold;
    color: #1a365d;
    margin-bottom: 4px;
    letter-spacing: 0.8px;
}

.university-address {
    font-size: 10px;
    color: #4a5568;
    margin-bottom: 2px;
}

.university-contact {
    font-size: 9px;
    color: #4a5568;
    margin-bottom: 6px;
}

.cell-name {
    font-size: 16px;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 0;
}

.header-separator {
    height: 2px;
    background: #1a365d;
    margin: 10px 0;
}

.letter-title {
    font-size: 20px;
    font-weight: bold;
    color: #1a365d;
    text-align: center;
    margin: 10px 0;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Simple Letter Body */
.letter-body {
    flex: 1;
    font-size: 12px;
    line-height: 1.6;
}

.date-ref-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 11px;
}

.letter-body p {
    margin: 12px 0;
    font-size: 12px;
    line-height: 1.6;
}


/* Signatures Section - Single Row (4 signatures) */
.signatures-section {
    margin: 20px 0 15px 0;
    flex-shrink: 0;
}

.signature-row-single {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.signature-block-inline {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.signature-image-inline {
    width: 80px;
    height: auto;
    margin: 0 auto 5px auto;
    display: block;
    object-fit: contain;
}

.signature-details {
    text-align: center;
}

.signature-details p {
    margin: 2px 0;
    font-size: 10px;
    color: #2d3748;
    line-height: 1.3;
}

.signature-details p:first-child {
    font-weight: bold;
    font-size: 11px;
}

/* Full Page Document Footer */
.document-footer {
    margin-top: 15px;
    padding-top: 10px;
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.footer-left {
    flex: 1;
    padding-right: 20px;
}

.footer-right {
    text-align: right;
    flex: 0 0 auto;
}

.footer-left p, .footer-right p {
    margin: 2px 0;
    font-size: 9px;
    color: #4a5568;
    line-height: 1.3;
}

/* Letter Header Images */
.letter-logos {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 20px;
}

.letter-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
}

.letter-logo.university {
    height: 90px;
}

.letter-logo.innovation {
    height: 75px;
}

/* Signature Images */
.signature-image {
    width: 150px;
    height: auto;
    margin: 10px auto;
    display: block;
    object-fit: contain;
}

.signature-section {
    position: relative;
}

.signature-section .signature-image {
    margin-bottom: 5px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    color: white;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .header {
        padding: 20px;
    }
    
    .header-text h1 {
        font-size: 2rem;
    }
    
    .header-subtitle h2 {
        font-size: 1.4rem;
    }
    
    .form-card, .preview-card {
        padding: 20px;
    }
    
    .preview-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .action-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header-text h1 {
        font-size: 1.8rem;
    }
    
    .header-subtitle h2 {
        font-size: 1.2rem;
    }
    
    .letter-preview {
        padding: 20px;
    }
    
    .university-name {
        font-size: 1.5rem;
    }
    
    .cell-name {
        font-size: 1.1rem;
    }
    
    .letter-title {
        font-size: 1.2rem;
    }
    
    .university-logo, .innovation-logo {
        height: 45px;
    }
    
    .university-logo {
        height: 50px;
    }
    
    .letter-logos {
        padding: 0 10px;
        margin-bottom: 15px;
    }
    
    .letter-logo {
        height: 50px;
    }
    
    .letter-logo.university {
        height: 60px;
    }
    
    .letter-logo.innovation {
        height: 45px;
    }
    
    .signature-image {
        width: 100px;
    }
}

/* Print Styles - Compact A4 */
@media print {
    @page {
        size: A4;
        margin: 0;
    }
    
    body {
        background: white;
        margin: 0;
        padding: 0;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .header, .form-section, .preview-header, .footer {
        display: none;
    }
    
    .main-content {
        display: block;
    }
    
    .preview-card {
        background: white;
        box-shadow: none;
        border: none;
        padding: 0;
        margin: 0;
    }
    
    .letter-preview {
        box-shadow: none;
        border: none;
        padding: 0;
        margin: 0;
    }
    
    .letter-content {
        width: 210mm !important;
        height: 297mm !important;
        padding: 15mm !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        page-break-after: avoid !important;
    }
    
    .header-logo {
        height: 60px !important;
        width: auto !important;
    }
    
    .header-separator {
        height: 2px !important;
        background: #000 !important;
        margin: 10px 0 !important;
    }
    
    .signature-row {
        display: flex !important;
        justify-content: space-between !important;
        margin-bottom: 20px !important;
    }
    
    .signature-block {
        width: 48% !important;
        text-align: center !important;
    }
    
    .signature-image {
        width: 80px !important;
        height: auto !important;
        margin: 0 auto 5px auto !important;
        display: block !important;
    }
    
    .signature-details {
        text-align: center !important;
    }
    
    .signature-details p {
        margin: 2px 0 !important;
        font-size: 10px !important;
    }
    
    /* Ensure single page */
    .letter-body {
        page-break-inside: avoid !important;
    }
    
    .signatures-section {
        page-break-inside: avoid !important;
    }
}
