/**
 * WD Contracts - Frontend/Public Styles
 * Version: 1.0.0
 * 
 * Styles for the contract signing page and customer portal
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    --wdc-primary: #2271b1;
    --wdc-primary-hover: #135e96;
    --wdc-success: #00a32a;
    --wdc-success-bg: #edfaef;
    --wdc-warning: #dba617;
    --wdc-warning-bg: #fcf9e8;
    --wdc-error: #d63638;
    --wdc-error-bg: #fcf0f1;
    --wdc-text: #1d2327;
    --wdc-text-light: #646970;
    --wdc-border: #c3c4c7;
    --wdc-border-light: #f0f0f1;
    --wdc-bg: #f6f7f7;
    --wdc-white: #ffffff;
    --wdc-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --wdc-radius: 8px;
}

/* ==========================================================================
   Signing Page Layout
   ========================================================================== */

.wdc-signing-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.wdc-signing-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
.wdc-signing-header {
    text-align: center;
    margin-bottom: 30px;
}

.wdc-signing-logo {
    max-height: 60px;
    margin-bottom: 15px;
}

.wdc-signing-header h1 {
    color: var(--wdc-white);
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wdc-signing-header .wdc-subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    margin: 0;
}

/* Main Card */
.wdc-signing-card {
    background: var(--wdc-white);
    border-radius: var(--wdc-radius);
    box-shadow: var(--wdc-shadow), 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Progress Steps */
.wdc-progress-steps {
    display: flex;
    background: var(--wdc-bg);
    border-bottom: 1px solid var(--wdc-border-light);
}

.wdc-progress-step {
    flex: 1;
    padding: 15px 20px;
    text-align: center;
    position: relative;
    color: var(--wdc-text-light);
    font-size: 14px;
    font-weight: 500;
}

.wdc-progress-step::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
    border-left: 12px solid var(--wdc-bg);
}

.wdc-progress-step:last-child::after {
    display: none;
}

.wdc-progress-step.active {
    background: var(--wdc-white);
    color: var(--wdc-primary);
}

.wdc-progress-step.active::after {
    border-left-color: var(--wdc-white);
}

.wdc-progress-step.completed {
    background: var(--wdc-success-bg);
    color: var(--wdc-success);
}

.wdc-progress-step.completed::after {
    border-left-color: var(--wdc-success-bg);
}

.wdc-progress-step .step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--wdc-border);
    color: var(--wdc-white);
    font-size: 12px;
    font-weight: 600;
    margin-right: 8px;
}

.wdc-progress-step.active .step-number {
    background: var(--wdc-primary);
}

.wdc-progress-step.completed .step-number {
    background: var(--wdc-success);
}

/* ==========================================================================
   Contract Content Section
   ========================================================================== */

.wdc-contract-section {
    padding: 30px;
}

.wdc-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--wdc-text);
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wdc-section-title .dashicons {
    color: var(--wdc-primary);
}

/* Contract Preview */
.wdc-contract-preview {
    background: var(--wdc-white);
    border: 1px solid var(--wdc-border);
    border-radius: var(--wdc-radius);
    padding: 30px;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Times New Roman', Times, serif;
    font-size: 14px;
    line-height: 1.7;
    color: #333;
}

.wdc-contract-preview h1 {
    font-size: 24px;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #333;
    padding-bottom: 15px;
}

.wdc-contract-preview h2 {
    font-size: 18px;
    margin: 25px 0 15px;
}

.wdc-contract-preview h3 {
    font-size: 16px;
    margin: 20px 0 10px;
}

.wdc-contract-preview p {
    margin-bottom: 12px;
    text-align: justify;
}

.wdc-contract-preview ul,
.wdc-contract-preview ol {
    margin: 15px 0;
    padding-left: 25px;
}

.wdc-contract-preview li {
    margin-bottom: 8px;
}

/* Scroll indicator */
.wdc-scroll-indicator {
    text-align: center;
    padding: 15px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
    margin-top: -50px;
    position: relative;
}

.wdc-scroll-indicator span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--wdc-text-light);
    font-size: 13px;
}

/* ==========================================================================
   Signature Section
   ========================================================================== */

.wdc-signature-section {
    padding: 30px;
    background: var(--wdc-bg);
    border-top: 1px solid var(--wdc-border-light);
}

.wdc-signature-wrapper {
    background: var(--wdc-white);
    border-radius: var(--wdc-radius);
    padding: 25px;
    box-shadow: var(--wdc-shadow);
}

/* Signature Canvas */
.wdc-signature-canvas-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.wdc-signature-canvas {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--wdc-border);
    border-radius: var(--wdc-radius);
    background: var(--wdc-white);
    cursor: crosshair;
    touch-action: none;
}

.wdc-signature-canvas.has-signature {
    border-style: solid;
    border-color: var(--wdc-success);
}

.wdc-signature-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--wdc-text-light);
    font-size: 14px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.wdc-signature-canvas.has-signature + .wdc-signature-placeholder {
    opacity: 0;
}

/* Signature Actions */
.wdc-signature-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.wdc-btn-clear {
    padding: 8px 16px;
    background: var(--wdc-white);
    border: 1px solid var(--wdc-border);
    border-radius: 4px;
    color: var(--wdc-text);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.wdc-btn-clear:hover {
    background: var(--wdc-bg);
    border-color: var(--wdc-text-light);
}

/* Signer Name Input */
.wdc-signer-name {
    margin-bottom: 20px;
}

.wdc-signer-name label {
    display: block;
    font-weight: 600;
    color: var(--wdc-text);
    margin-bottom: 8px;
    font-size: 14px;
}

.wdc-signer-name label .required {
    color: var(--wdc-error);
}

.wdc-signer-name input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--wdc-border);
    border-radius: 4px;
    font-size: 15px;
    transition: border-color 0.2s ease;
}

.wdc-signer-name input:focus {
    outline: none;
    border-color: var(--wdc-primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

/* ==========================================================================
   Consent Section
   ========================================================================== */

.wdc-consent-section {
    padding: 20px;
    background: var(--wdc-warning-bg);
    border: 1px solid rgba(219, 166, 23, 0.3);
    border-radius: var(--wdc-radius);
    margin-bottom: 20px;
}

.wdc-consent-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.wdc-consent-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}

.wdc-consent-checkbox label {
    font-size: 14px;
    line-height: 1.5;
    color: var(--wdc-text);
    cursor: pointer;
}

.wdc-consent-checkbox label strong {
    display: block;
    margin-bottom: 5px;
}

/* ==========================================================================
   Submit Section
   ========================================================================== */

.wdc-submit-section {
    padding: 25px 30px;
    background: var(--wdc-white);
    border-top: 1px solid var(--wdc-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.wdc-submit-info {
    font-size: 13px;
    color: var(--wdc-text-light);
}

.wdc-submit-info .dashicons {
    vertical-align: middle;
    margin-right: 5px;
}

.wdc-btn-submit {
    padding: 14px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: var(--wdc-radius);
    color: var(--wdc-white);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wdc-btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.wdc-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.wdc-btn-submit .wdc-spinner {
    display: none;
}

.wdc-btn-submit.loading .wdc-spinner {
    display: inline-block;
}

.wdc-btn-submit.loading .btn-text {
    display: none;
}

/* Spinner */
.wdc-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--wdc-white);
    border-radius: 50%;
    animation: wdc-spin 0.8s linear infinite;
}

@keyframes wdc-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Success State
   ========================================================================== */

.wdc-success-state {
    text-align: center;
    padding: 60px 30px;
}

.wdc-success-icon {
    width: 80px;
    height: 80px;
    background: var(--wdc-success-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
    animation: wdc-pop 0.5s ease;
}

@keyframes wdc-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.wdc-success-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--wdc-success);
    stroke-width: 3;
}

.wdc-success-state h2 {
    font-size: 24px;
    color: var(--wdc-text);
    margin: 0 0 15px;
}

.wdc-success-state p {
    font-size: 16px;
    color: var(--wdc-text-light);
    margin: 0 0 30px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.wdc-success-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.wdc-btn-secondary {
    padding: 12px 25px;
    background: var(--wdc-white);
    border: 1px solid var(--wdc-border);
    border-radius: 6px;
    color: var(--wdc-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.wdc-btn-secondary:hover {
    background: var(--wdc-bg);
    border-color: var(--wdc-text-light);
    color: var(--wdc-text);
}

/* ==========================================================================
   Error States
   ========================================================================== */

.wdc-error-state {
    text-align: center;
    padding: 60px 30px;
}

.wdc-error-icon {
    width: 80px;
    height: 80px;
    background: var(--wdc-error-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
}

.wdc-error-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--wdc-error);
    stroke-width: 3;
}

.wdc-error-state h2 {
    font-size: 24px;
    color: var(--wdc-text);
    margin: 0 0 15px;
}

.wdc-error-state p {
    font-size: 16px;
    color: var(--wdc-text-light);
    margin: 0;
}

/* Validation errors */
.wdc-field-error {
    color: var(--wdc-error);
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.wdc-field-error.visible {
    display: block;
}

input.error,
.wdc-signature-canvas.error {
    border-color: var(--wdc-error) !important;
}

/* ==========================================================================
   Already Signed State
   ========================================================================== */

.wdc-already-signed {
    text-align: center;
    padding: 40px 30px;
    background: var(--wdc-success-bg);
}

.wdc-already-signed h3 {
    margin: 0 0 10px;
    color: var(--wdc-success);
    font-size: 18px;
}

.wdc-already-signed p {
    margin: 0;
    color: var(--wdc-text-light);
}

/* ==========================================================================
   My Account - Contracts List (WooCommerce)
   ========================================================================== */

.wdc-myaccount-contracts {
    margin-top: 20px;
}

.wdc-contracts-list {
    width: 100%;
    border-collapse: collapse;
}

.wdc-contracts-list th,
.wdc-contracts-list td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--wdc-border-light);
}

.wdc-contracts-list th {
    background: var(--wdc-bg);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wdc-contracts-list tbody tr:hover {
    background: var(--wdc-bg);
}

.wdc-contracts-list .contract-title {
    font-weight: 500;
    color: var(--wdc-text);
}

.wdc-contracts-list .contract-date {
    color: var(--wdc-text-light);
    font-size: 13px;
}

/* Status badges for My Account */
.wdc-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.wdc-status-badge.status-pending {
    background: var(--wdc-warning-bg);
    color: #9a6700;
}

.wdc-status-badge.status-signed {
    background: var(--wdc-success-bg);
    color: #007017;
}

.wdc-status-badge.status-voided {
    background: var(--wdc-error-bg);
    color: #8a2424;
}

.wdc-status-badge.status-expired {
    background: #f0f0f1;
    color: #50575e;
}

/* Action buttons */
.wdc-contracts-list .actions {
    white-space: nowrap;
}

.wdc-contracts-list .actions a {
    display: inline-block;
    padding: 6px 12px;
    font-size: 12px;
    text-decoration: none;
    border-radius: 4px;
    margin-right: 5px;
}

.wdc-contracts-list .actions .btn-sign {
    background: var(--wdc-primary);
    color: var(--wdc-white);
}

.wdc-contracts-list .actions .btn-sign:hover {
    background: var(--wdc-primary-hover);
}

.wdc-contracts-list .actions .btn-view {
    background: var(--wdc-bg);
    color: var(--wdc-text);
    border: 1px solid var(--wdc-border);
}

.wdc-contracts-list .actions .btn-view:hover {
    background: var(--wdc-border-light);
}

/* Empty state for My Account */
.wdc-no-contracts {
    text-align: center;
    padding: 40px 20px;
    color: var(--wdc-text-light);
}

.wdc-no-contracts .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: var(--wdc-border);
    margin-bottom: 15px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.wdc-signing-footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.wdc-signing-footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.wdc-signing-footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .wdc-signing-page {
        padding: 20px 15px;
    }
    
    .wdc-signing-header h1 {
        font-size: 22px;
    }
    
    .wdc-progress-steps {
        flex-direction: column;
    }
    
    .wdc-progress-step {
        border-bottom: 1px solid var(--wdc-border-light);
    }
    
    .wdc-progress-step::after {
        display: none;
    }
    
    .wdc-progress-step:last-child {
        border-bottom: none;
    }
    
    .wdc-contract-section,
    .wdc-signature-section {
        padding: 20px;
    }
    
    .wdc-contract-preview {
        padding: 20px;
        max-height: 350px;
    }
    
    .wdc-submit-section {
        flex-direction: column;
        text-align: center;
    }
    
    .wdc-btn-submit {
        width: 100%;
        justify-content: center;
    }
    
    /* My Account responsive */
    .wdc-contracts-list {
        display: block;
        overflow-x: auto;
    }
    
    .wdc-contracts-list thead {
        display: none;
    }
    
    .wdc-contracts-list tbody tr {
        display: block;
        margin-bottom: 15px;
        background: var(--wdc-bg);
        border-radius: var(--wdc-radius);
        padding: 15px;
    }
    
    .wdc-contracts-list tbody td {
        display: block;
        border: none;
        padding: 5px 0;
    }
    
    .wdc-contracts-list tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 10px;
    }
    
    .wdc-contracts-list .actions {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--wdc-border-light);
    }
}

@media (max-width: 480px) {
    .wdc-signature-canvas {
        height: 150px;
    }
    
    .wdc-success-actions {
        flex-direction: column;
    }
    
    .wdc-success-actions a,
    .wdc-success-actions button {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wdc-signing-page {
        background: none;
        padding: 0;
    }
    
    .wdc-signing-header,
    .wdc-progress-steps,
    .wdc-signature-section,
    .wdc-submit-section,
    .wdc-signing-footer {
        display: none;
    }
    
    .wdc-signing-card {
        box-shadow: none;
        border: none;
    }
    
    .wdc-contract-preview {
        max-height: none;
        overflow: visible;
        border: none;
        padding: 0;
    }
}
