/* Sign PDF - Custom Tool View Styles */

.btn-primary {
    border: none;
    background: linear-gradient(135deg, #FF5A3C, #FF8A3D);
    color: #ffffff !important;
    border-radius: 10px;
    padding: 13px 22px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(255, 90, 60, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(255, 90, 60, 0.3);
}

.main-layout {
    display: grid;
    grid-template-columns: 1.75fr 0.82fr;
    gap: 30px;
    align-items: start;
    width: 100%;
}

.card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.06);
}

.dropzone {
    border: 2px dashed #a78bfa;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff, #faf7ff);
    min-height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 18px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #FF5A3C, #FF8A3D);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 15px;
}

.dropzone h3 {
    font-size: 18px;
    margin-bottom: 8px;
    font-weight: 750;
    color: #0f172a;
}

.dropzone .or {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 12px;
}

.dropzone p {
    margin-top: 14px;
    color: #64748b;
    font-size: 14px;
}

.workspace {
    overflow: hidden;
    width: 100%;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.file-main {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pdf-icon {
    width: 42px;
    height: 50px;
    border-radius: 8px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.pdf-icon::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    border-top: 12px solid #fecaca;
    border-left: 12px solid transparent;
    border-radius: 0 8px 0 0;
}

.file-title {
    font-weight: 800;
    margin-bottom: 5px;
    font-size: 15px;
}

.file-meta {
    color: #64748b;
    font-size: 14px;
}

.remove-btn {
    border: none;
    background: transparent;
    color: #0f172a;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: color 0.15s;
}

.remove-btn:hover {
    color: #ef4444;
}

.editor-area {
    display: grid;
    grid-template-columns: 170px 1fr;
    min-height: 480px;
    background: #fcfdfe;
}

.page-sidebar {
    border-right: 1px solid #e5e7eb;
    padding: 18px;
    background: #fbfdff;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-sidebar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-weight: 800;
    font-size: 14px;
    color: #0f172a;
}

.page-nav {
    display: flex;
    gap: 6px;
    align-items: center;
    color: #64748b;
}

.page-nav button {
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    transition: all 0.2s;
}

.page-nav button:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.thumb-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 580px;
    overflow-y: auto;
    padding-right: 6px;
}

.thumb-list::-webkit-scrollbar {
    width: 4px;
}

.thumb-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.thumb-item {
    text-align: center;
    cursor: pointer;
}

.thumb {
    width: 104px;
    height: 135px;
    margin: 0 auto 7px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    padding: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.02);
    transition: all 0.2s;
}

.thumb canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.thumb.active {
    border: 2px solid #FF8A3D;
    box-shadow: 0 8px 18px rgba(255, 138, 61, 0.12);
}

.thumb-num {
    font-size: 13px;
    font-weight: 800;
    color: #334155;
}

.pdf-workspace {
    padding: 16px 22px 20px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.tool-btn {
    height: 38px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 9px;
    padding: 0 14px;
    font-weight: 800;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
    font-size: 13px;
}

.tool-btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.tool-btn.active {
    border-color: #ddd6fe;
    background: #f5f3ff;
    color: #6d28d9;
}

.toolbar-spacer {
    flex: 1;
}

.sign-pages-wrap {
    overflow-y: auto;
    max-height: 620px;
    padding: 10px 10px 40px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    display: flex;
    justify-content: center;
}

.sign-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.sign-page-container {
    position: relative;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
    overflow: visible;
}

.sign-page-container canvas {
    display: block;
    border-radius: 12px;
}

.sign-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: crosshair;
}

.sign-overlay.select-mode {
    cursor: default;
}

.sign-overlay.hand-mode {
    cursor: grab;
}

.sign-page-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

/* Placed elements styling */
.signature-element {
    position: absolute;
    border: 2px dashed #FF8A3D;
    background: rgba(255, 138, 61, 0.03);
    cursor: move;
    z-index: 15;
    user-select: none;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signature-element img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.signature-element.selected,
.signature-element:hover {
    box-shadow: 0 0 0 2px rgba(255, 138, 61, 0.2);
}

.signature-delete,
.signature-resize {
    position: absolute;
    z-index: 20;
}

.signature-delete {
    top: -12px;
    right: -12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid white;
    background: #ba1a1a;
    color: white;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signature-resize {
    right: -6px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #FF8A3D;
    border: 1px solid white;
    cursor: se-resize;
}

.signature-element.locked {
    border: 1.5px solid transparent;
    background: transparent;
    cursor: default;
}

.signature-element.locked .signature-resize,
.signature-element.locked .signature-delete {
    display: none !important;
}

/* Settings Sidebar Options */
.settings-card {
    padding: 28px;
}

.settings-card h2 {
    font-size: 21px;
    margin-bottom: 26px;
    font-weight: 850;
    color: #0f172a;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    color: #0f172a;
    font-size: 15px;
    margin-bottom: 9px;
    font-weight: 800;
}

.tab-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 18px;
}

.tab {
    height: 42px;
    border: none;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    font-weight: 800;
    cursor: pointer;
    color: #334155;
    transition: all 0.15s;
}

.tab:last-child {
    border-right: none;
}

.tab.active {
    background: #f5f3ff;
    color: #6d28d9;
    box-shadow: inset 0 0 0 1px #FF8A3D;
}

.signature-mode-panel {
    display: none;
}

.signature-mode-panel.active {
    display: block;
}

#signature-canvas {
    width: 100%;
    aspect-ratio: 2.8 / 1;
    background: white;
    border: 1px dashed rgba(255, 138, 61, 0.4);
    border-radius: 8px;
    touch-action: none;
}

.signature-canvas-actions {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.clear-signature-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 800;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.clear-signature-btn:hover {
    background: #f8fafc;
}

.signature-input,
.signature-select {
    width: 100%;
    height: 48px;
    border: 1px solid #dbe1ea;
    border-radius: 10px;
    padding: 0 14px;
    font-weight: 800;
    outline: none;
    color: #0f172a;
    margin-bottom: 12px;
}

.signature-input:focus,
.signature-select:focus {
    border-color: #FF8A3D;
}

.typed-preview {
    min-height: 92px;
    border: 1px dashed rgba(255, 138, 61, 0.4);
    border-radius: 8px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font-size: 34px;
    line-height: 1;
    overflow: hidden;
    padding: 8px;
    margin-bottom: 12px;
}

.signature-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s;
    margin-bottom: 12px;
    padding: 12px;
}

.signature-upload-area:hover {
    border-color: #FF8A3D;
}

.signature-upload-area .upload-icon {
    font-size: 26px;
    margin-bottom: 6px;
    color: #64748b;
}

.signature-upload-area span {
    font-size: 13px;
    font-weight: 800;
    color: #475569;
}

.uploaded-preview-img {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
}

.use-signature-action-btn {
    width: 100%;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, #FF5A3C, #FF8A3D);
    color: white;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(255, 90, 60, 0.15);
    margin-bottom: 12px;
}

.use-signature-action-btn:hover {
    opacity: 0.95;
}

.signature-hint-text {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
    font-weight: 600;
    margin-bottom: 14px;
}

/* Color dot selector */
.color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.color-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.15s;
}

.color-dot:hover {
    transform: scale(1.1);
}

.color-dot.active {
    outline: 3px solid #FF8A3D;
    outline-offset: 2px;
    border-color: #ffffff;
}

.black { background: #020617; }
.blue-dot { background: #2563eb; }
.red { background: #ef4444; }
.purple-dot { background: #FF8A3D; }
.green-dot { background: #16a34a; }

/* Size controls */
.size-row {
    display: grid;
    grid-template-columns: 1fr 64px 24px;
    align-items: center;
    gap: 12px;
}

.range {
    width: 100%;
    accent-color: #FF8A3D;
    cursor: pointer;
}

.size-input {
    height: 40px;
    border: 1px solid #dbe1ea;
    border-radius: 9px;
    text-align: center;
    font-weight: 800;
    outline: none;
    font-size: 14px;
}

.size-input:focus {
    border-color: #FF8A3D;
}

/* Positions shortcut grid */
.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    overflow: hidden;
    width: 175px;
}

.pos-btn {
    height: 32px;
    border: none;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.pos-btn:nth-child(3n) {
    border-right: none;
}

.pos-btn:nth-child(n+4) {
    border-bottom: none;
}

.pos-btn.active {
    background: #f5f3ff;
    color: #6d28d9;
    box-shadow: inset 0 0 0 1px #FF8A3D;
}

/* Locking / additional check checkbox */
.checkbox-option {
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 12px;
    align-items: start;
    margin-bottom: 24px;
    cursor: pointer;
}

.checkbox-option input {
    width: 18px;
    height: 18px;
    accent-color: #FF8A3D;
    margin-top: 2px;
    cursor: pointer;
}

.option-title {
    font-weight: 800;
    margin-bottom: 4px;
    color: #334155;
}

.option-desc {
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
}

.apply-btn {
    width: 100%;
    height: 58px;
    font-size: 17px;
    border-radius: 12px;
}

.safe-note {
    margin-top: 17px;
    text-align: center;
    color: #64748b;
    font-size: 14px;
    line-height: 1.5;
}

.safe-note strong {
    color: #16a34a;
}

/* Features list grid */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin-top: 18px;
    overflow: hidden;
}

.feature {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    padding: 28px 34px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.feature:first-child {
    border-radius: 18px 0 0 18px;
}

.feature:last-child {
    border-radius: 0 18px 18px 0;
}

.feature-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.green {
    background: #dcfce7;
    color: #16a34a;
}

.purple {
    background: #f3e8ff;
    color: #FF8A3D;
}

.blue {
    background: #dbeafe;
    color: #2563eb;
}

.feature h3 {
    font-size: 18px;
    margin-bottom: 7px;
    font-weight: 750;
    color: #0f172a;
}

.feature p {
    color: #64748b;
    font-size: 14px;
    line-height: 1.5;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Responsive CSS */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .editor-area {
        grid-template-columns: 1fr;
    }

    .page-sidebar {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .thumb-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 8px;
    }

    .thumb {
        margin: 0 6px 0 0;
        display: inline-block;
    }

    .features {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature,
    .feature:first-child,
    .feature:last-child {
        border-radius: 18px;
    }
}

@media (max-width: 640px) {
    .page {
        padding: 24px 16px 40px;
    }

    .page-title h1 {
        font-size: 30px;
    }

    .editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .tool-btn {
        width: 100%;
    }
}
