/**
 * ROBIS Lab - iPaste Subsystem
 * Modern, Responsive UI Stylesheet
 */

:root {
    --bg-main: #0b0f19;
    --bg-card: #151d30;
    --bg-card-hover: #1c2640;
    --bg-input: #0e1526;
    --border-color: #24324f;
    --border-focus: #38bdf8;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Header & Navigation */
.ipaste-header {
    background: #0d1322;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.ipaste-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.ipaste-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.ipaste-logo-badge {
    background: linear-gradient(135deg, #6366f1, #38bdf8);
    color: #ffffff;
    font-weight: 800;
    font-size: 1.25rem;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.ipaste-brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.ipaste-brand-title span {
    color: var(--accent);
}

.ipaste-brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ipaste-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

/* Layout container */
.ipaste-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    width: 100%;
    flex: 1;
}

/* Hero & Subheader */
.ipaste-hero {
    text-align: center;
    margin-bottom: 30px;
}

.ipaste-hero h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ipaste-hero p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Dropzone & Upload Panel */
.upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
}

.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.05);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.15);
}

.dropzone-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    color: var(--accent);
    display: inline-block;
}

.dropzone-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.dropzone-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.dropzone-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-accent {
    background-color: var(--accent);
    color: #0b0f19;
}

.btn-accent:hover:not(:disabled) {
    background-color: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}

.btn-success:hover:not(:disabled) {
    background-color: var(--success-hover);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
}

.btn-outline-danger {
    background-color: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover:not(:disabled) {
    background-color: rgba(239, 68, 68, 0.12);
    border-color: #dc2626;
    color: #f87171;
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

/* Result Card */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-top: 24px;
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.result-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 8px;
}

.url-box-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.url-input {
    flex: 1;
    min-width: 280px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--accent);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
}

.url-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Checkered Canvas/Preview Container */
.preview-container {
    background: #111625;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    max-height: 650px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
    /* Subtle transparency checkerboard */
    background-image: linear-gradient(45deg, #161d30 25%, transparent 25%), 
                      linear-gradient(-45deg, #161d30 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #161d30 75%), 
                      linear-gradient(-45deg, transparent 75%, #161d30 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.preview-img {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 550px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    display: block;
    margin: 0 auto;
}

/* Quick Tools Action Bar */
.quick-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

/* Webcam Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 640px;
    width: 100%;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.25s ease;
}

@keyframes modalPop {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.webcam-video-wrap {
    width: 100%;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

#webcam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

/* ========================================================
 * Annotation Studio Specific Styles
 * ======================================================== */
.annotate-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.annotate-toolbar {
    background: #111827;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    user-select: none;
    z-index: 50;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 10px;
    border-right: 1px solid var(--border-color);
}

.tool-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    font-family: inherit;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.tool-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.tool-select, .tool-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
}

.tool-select:focus, .tool-input:focus {
    outline: none;
    border-color: var(--accent);
}

.tool-color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    padding: 0;
}

.tool-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.tool-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Annotate Canvas Workspace */
.annotate-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: hidden;
    width: 100%;
    max-width: 100vw;
}

.annotate-workspace {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    background: #090d16;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
    touch-action: none; /* Crucial for touchscreen drawing */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.annotate-canvas-card {
    position: relative;
    box-shadow: var(--shadow-lg);
    background-color: #ffffff;
    border-radius: 2px;
    user-select: none;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#annotation-canvas {
    display: block;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.preset-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.preset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(56, 189, 248, 0.08);
}

/* Crop selection rectangle overlay */
.crop-overlay {
    position: absolute;
    border: 2px dashed #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    pointer-events: none;
    display: none;
}

/* Floating Save Result Toast/Dialog */
.save-dialog {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    max-width: 450px;
    width: calc(100% - 60px);
    z-index: 2000;
    display: none;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Global Toast Notification */
.toast-msg {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
}

.toast-msg.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* Footer */
.ipaste-footer {
    text-align: center;
    padding: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: #0d1322;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ipaste-header-inner {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ipaste-hero h1 {
        font-size: 1.6rem;
    }
    
    .dropzone {
        padding: 30px 10px;
    }
    
    .annotate-toolbar {
        gap: 6px;
    }
    
    .tool-group {
        border-right: none;
        padding-right: 0;
    }
}
