/**
 * Digital Circular & Teacher Acknowledgement Portal
 * Public & Teacher Interface Stylesheet
 */

:root {
    --primary: #1e3a8a;          /* Deep Oxford Blue */
    --primary-light: #2563eb;
    --primary-dark: #172554;
    --accent: #d97706;           /* Academic Gold / Amber */
    --accent-light: #fef3c7;
    --text-main: #0f172a;        /* Slate 900 */
    --text-muted: #64748b;       /* Slate 500 */
    --bg-page: #f8fafc;          /* Slate 50 */
    --bg-card: #ffffff;
    --border-color: #e2e8f0;     /* Slate 200 */
    --border-focus: #3b82f6;
    --success: #15803d;          /* Forest Green */
    --success-bg: #f0fdf4;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Merriweather", Georgia, "Times New Roman", serif;
}

/* Global Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--text-main);
    background-color: var(--bg-page);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar / Portal Header */
.portal-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.portal-navbar .nav-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--primary-dark);
}

.portal-brand img {
    height: 42px;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
}

.portal-brand-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    color: var(--primary);
}

.portal-brand-text span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Main Container */
.main-wrapper {
    flex: 1;
    padding: 1.5rem 1rem 3rem;
    display: flex;
    justify-content: center;
}

.circular-container {
    width: 100%;
    max-width: 860px;
}

/* Official Document Card */
.document-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 2rem;
}

/* School Letterhead Header */
.letterhead-header {
    padding: 2.25rem 2rem 1.5rem;
    background: #ffffff;
    text-align: center;
    position: relative;
}

.letterhead-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.letterhead-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    padding: 3px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.letterhead-title {
    font-family: var(--font-serif);
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.3px;
    line-height: 1.25;
}

.letterhead-address {
    font-size: 0.92rem;
    color: #475569;
    max-width: 600px;
    line-height: 1.4;
}

.letterhead-contact {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.letterhead-contact span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.letterhead-contact a {
    color: var(--primary-light);
    text-decoration: none;
}

.letterhead-contact a:hover {
    text-decoration: underline;
}

/* Official Horizontal Divider */
.letterhead-divider {
    margin: 1.5rem 0 0.5rem;
    height: 4px;
    background: linear-gradient(90deg, #1e3a8a 0%, #3b82f6 50%, #1e3a8a 100%);
    border-radius: 2px;
    position: relative;
}

.letterhead-divider::after {
    content: "★";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 0 10px;
    color: var(--accent);
    font-size: 0.9rem;
}

/* Document Meta Badge Section */
.circular-meta-banner {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
}

.circular-badge-header {
    text-align: center;
    margin-bottom: 1rem;
}

.circular-badge-header h2 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary-dark);
    display: inline-block;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 4px;
}

.circular-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    background: #ffffff;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-item .meta-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.meta-item .meta-val {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 0.15rem;
}

.meta-item.meta-subject {
    grid-column: 1 / -1;
}

.meta-item.meta-subject .meta-val {
    color: var(--primary-dark);
    font-size: 1.05rem;
    line-height: 1.35;
}

/* Circular Body Content */
.circular-body {
    padding: 2.25rem 2rem;
    font-size: 1.05rem;
    color: #1e293b;
    line-height: 1.8;
}

.circular-body p {
    margin-bottom: 1.25rem;
}

.circular-body h1, .circular-body h2, .circular-body h3, .circular-body h4 {
    color: var(--primary-dark);
    margin: 1.5rem 0 0.75rem;
    line-height: 1.3;
}

.circular-body ul, .circular-body ol {
    margin: 0.75rem 0 1.25rem 1.5rem;
}

.circular-body li {
    margin-bottom: 0.5rem;
}

.circular-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.circular-body th, .circular-body td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.circular-body th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--primary-dark);
}

.circular-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 0.75rem 1.25rem;
    margin: 1.25rem 0;
    background: #fffbeb;
    font-style: italic;
    color: #92400e;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Acknowledgement Form Section */
.acknowledgement-section {
    background: #ffffff;
    border-top: 2px dashed var(--border-color);
    padding: 2.25rem 2rem;
}

.ack-header {
    margin-bottom: 1.5rem;
}

.ack-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ack-header p {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Checkbox Confirmation Card */
.declaration-box {
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.declaration-box:hover {
    border-color: var(--primary-light);
    background: #f1f5f9;
}

.declaration-box.checked {
    border-color: var(--primary);
    background: #eff6ff;
}

.declaration-label {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    user-select: none;
}

.declaration-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

/* Input Fields */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.form-label .required {
    color: var(--danger);
}

.form-control-lg {
    width: 100%;
    padding: 0.9rem 1.1rem;
    font-size: 1.05rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    background-color: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.form-control-lg:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* Signature Pad Area */
.signature-card {
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.signature-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.signature-prompt {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.signature-tools {
    display: flex;
    gap: 0.5rem;
}

.btn-tool {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: #475569;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-tool:hover {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: #94a3b8;
}

.canvas-wrapper {
    background: #ffffff;
    border: 1.5px dashed #94a3b8;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

.canvas-wrapper canvas {
    display: block;
    width: 100%;
    height: 180px;
    touch-action: none;
    cursor: crosshair;
}

.canvas-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: #cbd5e1;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    transition: opacity 0.2s ease;
}

.canvas-wrapper.has-strokes .canvas-watermark {
    opacity: 0;
}

/* Submit Action Button */
.btn-submit-ack {
    width: 100%;
    padding: 1.1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 56px; /* Touch-friendly size */
}

.btn-submit-ack:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 6px 16px rgba(30, 58, 138, 0.35);
    transform: translateY(-1px);
}

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

.btn-submit-ack:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.spinner-border {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    vertical-align: text-bottom;
    border: 0.2em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Success Card Screen */
.success-screen {
    text-align: center;
    padding: 3rem 2rem;
    display: none;
}

.success-icon-wrap {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem;
    border: 3px solid #bbf7d0;
    animation: pulse-success 1.5s infinite;
}

@keyframes pulse-success {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    70% { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.success-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.success-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto 1.75rem;
}

.receipt-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    max-width: 500px;
    margin: 0 auto 2rem;
    text-align: left;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95rem;
}

.receipt-row:last-child {
    border-bottom: none;
}

.receipt-row .label {
    color: var(--text-muted);
    font-weight: 500;
}

.receipt-row .val {
    color: var(--text-main);
    font-weight: 700;
    text-align: right;
}

.receipt-signature-img {
    max-height: 48px;
    max-width: 140px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    padding: 2px;
}

.btn-done {
    background: var(--primary);
    color: #fff;
    padding: 0.85rem 2.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-done:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* Already Submitted Alert Banner */
.submitted-device-alert {
    background: #ecfdf5;
    border: 1.5px solid #a7f3d0;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.submitted-device-alert .alert-icon {
    font-size: 1.5rem;
    color: var(--success);
    flex-shrink: 0;
}

.submitted-device-alert .alert-body h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #065f46;
    margin-bottom: 0.25rem;
}

.submitted-device-alert .alert-body p {
    font-size: 0.9rem;
    color: #047857;
    margin-bottom: 0.75rem;
}

.btn-secondary-sm {
    background: #ffffff;
    border: 1px solid #6ee7b7;
    color: #065f46;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary-sm:hover {
    background: #d1fae5;
}

/* Toast Notifications Container */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 90vw;
}

.custom-toast {
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    min-width: 280px;
    max-width: 420px;
    animation: toast-in 0.3s ease;
}

.custom-toast.toast-success {
    border-left-color: var(--success);
}

.custom-toast.toast-error {
    border-left-color: var(--danger);
}

.custom-toast.toast-warning {
    border-left-color: var(--accent);
}

@keyframes toast-in {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Footer */
.portal-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: #ffffff;
}

/* Mobile Breakpoints & Responsiveness */
@media (max-width: 640px) {
    .letterhead-header {
        padding: 1.5rem 1rem 1rem;
    }

    .letterhead-logo {
        width: 70px;
        height: 70px;
    }

    .letterhead-title {
        font-size: 1.35rem;
    }

    .letterhead-address {
        font-size: 0.85rem;
    }

    .letterhead-contact {
        flex-direction: column;
        gap: 0.35rem;
    }

    .circular-meta-banner {
        padding: 1rem;
    }

    .circular-meta-grid {
        grid-template-columns: 1fr;
        padding: 0.75rem 1rem;
    }

    .circular-body {
        padding: 1.5rem 1rem;
        font-size: 0.98rem;
    }

    .acknowledgement-section {
        padding: 1.5rem 1rem;
    }

    .canvas-wrapper canvas {
        height: 160px;
    }

    .receipt-card {
        padding: 1rem;
    }
}

/* Print Optimization */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .portal-navbar,
    .acknowledgement-section,
    .submitted-device-alert,
    .toast-container,
    .portal-footer,
    .no-print {
        display: none !important;
    }

    .main-wrapper {
        padding: 0 !important;
    }

    .document-card {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    .letterhead-header {
        padding-top: 0 !important;
    }

    .letterhead-divider {
        background: #000000 !important;
    }

    .circular-body {
        padding: 1rem 0 !important;
    }
}
